It is currently 25 Feb 2021, 22:05

• Featuring Members' Works (Image Attachments) •
1: member
2: member
3: member
4: member
5: member

GIMP/GL:  Tutorials | Tips | Questions | 🡆 Interests | Script Requests
Recommendations:  Index | Top 10
Resources:  Python-Fu Plug-ins | Scheme-Fu Scripts | GIMP
Python:  Lessons | Questions | Exercises
The Arts:  GIMPed | GIMPed Photos | Other | Contests | Public Domain Images | Isolated Images | Blender
Inkscape
Social:  Say Hello | Anything Goes | Shares | FCSP

Topics/Posts by month graphs custom pages for phpbb 3.2

GIMP or GIMP LEARN Forum Interests
tim
GL Blogger

Topics/Posts by month graphs custom pages for phpbb 3.2

Post#1 by tim » 21 Feb 2017, 23:58


Graphing topics/posts by month for phpbb 3.2 (in our case, GIMP LEARN forum).
graph topics by month
graph posts by month

I used the below php code and google chart/graphs api

for graph topics by month

Code: Select all

<html>
  <head>
    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
    <script type="text/javascript">
      google.charts.load('current', {'packages':['corechart']});
      google.charts.setOnLoadCallback(drawChart);

      function drawChart() {
        var data = google.visualization.arrayToDataTable([
          ['Year-Mo', 'Topics']
<?php

//connect to your database
mysql_connect('localhost','bakon306_phpb537','password'); //(host, username, password)

//specify database
mysql_select_db('bakon306_phpb537') or die("Unable to select database"); //select which database we're using

$query = "
SELECT DATE_FORMAT(from_unixtime(topic_time),'%Y-%m') as dt,
       count(*) as count
FROM `phpbbsf_topics`
GROUP BY dt
ORDER BY dt";
 $numresults=mysql_query($query);
 $numrows=mysql_num_rows($numresults);
// next determine if s has been passed to script, if not use 0
// get results
  #$query .= " limit 30";
  $result = mysql_query($query) or die("Couldn't execute query");




// now you can display the results returned
	while ($row=mysql_fetch_array($result)) {
	  //$filename = $row["physical_filename"];
		$dt = $row["dt"];
		$count = $row["count"];
		print ",['".$dt."',".$count."]";
		#['2005',  1170,      460],
	}
?>
]);

        var options = {
          title: 'Topics added by month',
          //curveType: 'function',
          legend: { position: 'bottom' }
        };

        var chart = new google.visualization.LineChart(document.getElementById('curve_chart'));

        chart.draw(data, options);
      }
    </script>
  </head>
  <body>
	Topics added by month graph on <a href="http://gimplearn.net/">GIMP LEARN forum</a><br/>
	<a href="http://gimplearn.net/styles/prosilver/template/graph_topics.php">graph topics by month</a><br/>
	<a href="http://gimplearn.net/styles/prosilver/template/graph_posts.php">graph posts by month</a><br/>
    <div id="curve_chart" style="width: 900px; height: 500px"></div>
  </body>
</html>
for graph posts by month

Code: Select all

<html>
  <head>
    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
    <script type="text/javascript">
      google.charts.load('current', {'packages':['corechart']});
      google.charts.setOnLoadCallback(drawChart);

      function drawChart() {
        var data = google.visualization.arrayToDataTable([
          ['Year-Mo', 'Posts']
<?php

//connect to your database
mysql_connect('localhost','bakon306_phpb537','password'); //(host, username, password)

//specify database
mysql_select_db('bakon306_phpb537') or die("Unable to select database"); //select which database we're using

$query = "
SELECT DATE_FORMAT(from_unixtime(post_time),'%Y-%m') as dt,
       count(*) as count
FROM `phpbbsf_posts`
GROUP BY dt
ORDER BY dt";
 $numresults=mysql_query($query);
 $numrows=mysql_num_rows($numresults);
// next determine if s has been passed to script, if not use 0
// get results
  #$query .= " limit 30";
  $result = mysql_query($query) or die("Couldn't execute query");




// now you can display the results returned
	while ($row=mysql_fetch_array($result)) {
	  //$filename = $row["physical_filename"];
		$dt = $row["dt"];
		$count = $row["count"];
		print ",['".$dt."',".$count."]";
		#['2005',  1170,      460],
	}
?>
]);

        var options = {
          title: 'Posts added by month',
          //curveType: 'function',
          legend: { position: 'bottom' }
        };

        var chart = new google.visualization.LineChart(document.getElementById('curve_chart'));

        chart.draw(data, options);
      }
    </script>
  </head>
  <body>
	Posts added by month graph on <a href="http://gimplearn.net/">GIMP LEARN forum</a><br/>
	<a href="http://gimplearn.net/styles/prosilver/template/graph_topics.php">graph topics by month</a><br/>
	<a href="http://gimplearn.net/styles/prosilver/template/graph_posts.php">graph posts by month</a><br/>
    <div id="curve_chart" style="width: 900px; height: 500px"></div>
  </body>
</html>
The two pages are nearly identical except for description and of graph and query.
You'll have change database, username and password for your own phpbb forum if you want to use it.
aka Tin

         

tim
GL Blogger

Post#2 by tim » 25 Jul 2017, 18:57


Added link on bottom of pages called TPSA (Topics/Posts/Sessions/Attachments) Graphs
Where you can view 4 different graphs
tpsa_graphs.php?graph=Topics
tpsa_graphs.php?graph=Posts
tpsa_graphs.php?graph=Sessions
tpsa_graphs.php?graph=Attachments
aka Tin

         


GIMP/GL:  Tutorials | Tips | Questions | 🡆 Interests | Script Requests
Recommendations:  Index | Top 10
Resources:  Python-Fu Plug-ins | Scheme-Fu Scripts | GIMP
Python:  Lessons | Questions | Exercises
The Arts:  GIMPed | GIMPed Photos | Other | Contests | Public Domain Images | Isolated Images | Blender
Inkscape
Social:  Say Hello | Anything Goes | Shares | FCSP

Post Reply New Topic
  • Similar Topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 7 guests