mklappen Posted September 26, 2005 Posted September 26, 2005 Hi, On my home page I would like to display a list of my most popular pages based on user visits. The majority of my pages are html. Almost all of the of php counters I've seen require me to add php but, I'd prefer not to convert my static pages to php. Does anyone have recommendations on how to count hits to html pages, store in flat file or mysql db and then retrieve the "top 5" or "top 10" ? Can I pull this from awstats somehow? Thanks mk Quote
TCH-Don Posted September 26, 2005 Posted September 26, 2005 Welcome to the forum mk To use php scripts in your html files add AddHandler application/x-httpd-php .htm .html to your .htaccess file then your server will look at your html and htm files for php code and run the php code it finds. Now you can look at hotscripts.com for a script to do what you want. Quote
TweezerMan Posted September 26, 2005 Posted September 26, 2005 Welcome to the forums, mklappen! Quote
TCH-Rob Posted September 26, 2005 Posted September 26, 2005 Welcome to the forums, mklappen. Dons option should do the trick. Quote
mklappen Posted September 27, 2005 Author Posted September 27, 2005 Welcome to the forums! great, thanks for the posts. I'll try it out Mike Quote
mklappen Posted September 28, 2005 Author Posted September 28, 2005 Hi, Since I got such a fast/good response I my first post I was hoping someone could help me out. I added the AddHandler line to my .htaaccess but instead of going to HotScripts or PHP Freaks to find a counter script, I decided to create my own. Below is the script/DB queries I'm trying to test(I will expand it later), I also added <?php @include_once("counter.php");?> to an html file to test. <?php> require_once('mysql_connect.php'); $URL=$_SERVER['HTTP_REFERER']; $q = "SELECT * FROM counter where url='$URL'"; $r = mysql_query($q); $rw = mysql_fetch_array($r, MYSQL_ASSOC); $count = $rw['count']; $dt = date("Y-m-d"); if($rw['url'] && $rw['date'] == $dt) $qu = mysql_query("UPDATE counter SET count = '$count + 1' WHERE url='$URL'"); else $qu = mysql_query("INSERT INTO counter(url, count, date) VALUES ('$URL', '1', '$dt'"); // first entry ?> My problem occurs with the $URL variable. It's not being passed the url of the html page that is calling the script. I tried setting $_SERVER['PHP_SELF'] but that just sets $URL="counter.php" Does anyone know what I'm doing wrong? I've looked on php.net for other variables but don't know which would cover what I'm trying to do. Thanks! Mike Quote
mklappen Posted September 28, 2005 Author Posted September 28, 2005 Please disregard.... the query: $qu = mysql_query("INSERT INTO counter(url, count, date) VALUES ('$URL', '1', '$dt'"); was missing a close paren at the end, should have been. $qu = mysql_query("INSERT INTO counter(url, count, date) VALUES ('$URL', '1', '$dt')"); Thanks! Quote
TCH-Don Posted September 28, 2005 Posted September 28, 2005 on your first line <?php> you should remove the last charater > it is just Quote
JTD Posted October 9, 2005 Posted October 9, 2005 Hi, On my home page I would like to display a list of my most popular pages based on user visits. The majority of my pages are html. Almost all of the of php counters I've seen require me to add php but, I'd prefer not to convert my static pages to php. Does anyone have recommendations on how to count hits to html pages, store in flat file or mysql db and then retrieve the "top 5" or "top 10" ? Can I pull this from awstats somehow? Thanks mk Have you looked into this Daily Counter 1.1 Then there is a tutorial here Daily Counter 1.1 modifications for including it into html pages Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.