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 - Showing Figures Based on the Statistics (Page 4 of 7 )
In a lot of cases the text-based statistics with two tables are enough, but figures made from the database can be more useful. What kind of figures can we make? Some examples: the number of the visitors on the days of the week, the page impressions ordered by the hours of the day, and the number of the reads of the pages.
Here we will make a chart to show how many pages the visitors downloaded. First of all, let's do the query:
, Count(ID) as Count_ID FROM hits GROUP BY Host ORDER BY Count_ID DESC LIMIT 0, 10
Use the LIMIT clause on only the first ten rows of the query. We don't want to see thousands of users on a figure, only the Top 10. ORDER BY is necessary to see the "top 10" visitors who read the most from your site.