Category Archives: Software Projects

Applications, tools, & code snippets from my software projects.

Adventures with Chart

Now that Chart is up and running I started working on the lmhist.php file.  The old version has numerous hard coded php files that generate each graph.  I have for some time now wanted to have the graphs be automated through a loop.

Automating Chart

The way Chart works is you call a separate php file for each image.

echo "<a><img src='graphic.php' border=0 align=center width=100 height=50></a>";

That’s great, but each of my graphic.php type files contain basically the same thing.  A SQL query to fetch the use data, license count, and the date.

It then calls Chart and adds the data.  Chart makes a png image file and returns it.  The file is named the same thing the graphic.php is.


I tried moving the SQL query into lmhist.php and then call a generic graphic.php file.  First problem to overcome is getting the array of data through from lmhist.php to graphic.php.  I settled on using session cookies and PHP’s global $_SESSION variable.  While it kind of worked all the graphs display the same data.

Then I realized that since the images are all named the same the image will contain the same image information because either the web server is only generating it once or the browser only requests it once.

What I came up with is to create separate image files like I had before, but automated.  In a loop I do my SQL query and fetch the data.  Then using the feature name I created a feature.php and copied the graphic.php into it.  The only new thing I had to do was use the file name to fetch the feature name to use in the SQL queries.

$feature = basename($scriptname, ".php");

This works.  The end result is a list of the summary feature data.


I had to add a few fields to the features table in the database to track what is active, a summary, etc.

What’s Next

Next step will be to figure out how to group the products together and chart each application type by year.