phpmysqlianalyticshitcounter

PHP page hit counters in database


I run a podcast network and I'm redoing my site from scratch. One of the features on my network is to listen to podcasts directly from the site in an HTML5 player. I have all that functionality working just fine, but I'd like some analytical data on those pages.

I'd like to make a hit counter in PHP and store it in a DB table. But, there's only one page. The player loads each show, dependent on the query string, then it pulls the latest episode from their RSS Feed, like so: http://tangentboundnetwork.com/new/show.php?id=1

I want to be able to put analytical data into a table and use it for the hosts of whatever show(s) are on the network.

I just need to know where to start. Any ideas, Links, and examples would be welcome.


Solution

  • First, create your database table VISITOR_COUNT. You will need at least two columns - SHOW_ID and COUNT.

    The code in show.php could look something like this: