Making usage statistics on a web site is one of the most enjoyable things for me on the Internet. Thanks to the technology, you can see each click of each visitor, the date of the visiting, and how many seconds the user was reading your site. I use this feature to track which of my articles was read for the longest time. In this article I will show you how to store the statistics in a MySQL database, show the web stats in an HTML table and make figures based on the stats using the GD library.
Making Usage Statistics in PHP - Creating the Image Library (Page 5 of 7 )
Having the data, let's start to deal with the image creation library of PHP (GD). Its output is GIF/PNG/JPEG. It uses image resources. These are PHP variables representing images. Usually, in a program there is only one image resource. You can create an image resource using one of the following functions:
ImageCreate (int width, int height) - Creates a blank image resource
ImageCreateTrueColor (int width, int height) - Creates a blank true color image resource
ImageCreateFromGIF (string filename) - Creates an image resource using a given picture file
ImageCreateFromJPEG (string filename) - Creates an image resource using a given picture file
ImageCreateFromPNG (string filename) - Creates an image resource using a given picture file
This code can be good for this, but don't forget to call the header function because it's not HTML output!