Daily Counter For Pages

liunx

Guest
Hi,<br /><br />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. <br /><br />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?<br />Thanks<br />mk<!--content-->
Welcome to the forum mk <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /><br /><br />To use php scripts in your html files add<br /><br /><!--fonto:Courier New--><span style="font-family:Courier New"><!--/fonto--><b>AddHandler application/x-httpd-php .htm .html</b><!--fontc--></span><!--/fontc--><br /><br />to your .htaccess file<br />then your server will look at your <b>html</b> and <b>htm</b> files for php code<br />and run the php code it finds.<br /><br />Now you can look at hotscripts.com for a script to do what you want.<!--content-->
Welcome to the forums, mklappen! <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/thumbup1.gif" style="vertical-align:middle" emoid=":thumbup1:" border="0" alt="thumbup1.gif" /><!--content-->
Welcome to the forums, mklappen. Dons option should do the trick.<!--content-->
Welcome to the forums, mklappen<!--content-->
Welcome to the forums!<!--content-->
<!--quoteo(post=150146:date=Sep 26 2005, 06:55 PM:name=TCH-Steve)--><div class='quotetop'>QUOTE(TCH-Steve @ Sep 26 2005, 06:55 PM) <a href="http://www.totalchoicehosting.com/forums/index.php?act=findpost&pid=150146"><img src='http://www.totalchoicehosting.com/forums/style_images/1/post_snapback.gif' alt='*' border='0' /></a></div><div class='quotemain'><!--quotec-->Welcome to the forums!<!--QuoteEnd--></div><!--QuoteEEnd--><br /><br />great, thanks for the posts. I'll try it out<br />Mike<!--content-->
Welcome to the forum, mklappen. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /><!--content-->
Hi,<br /><br />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. <br /><br />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. <br /><br /><?php><br />require_once('mysql_connect.php');<br /><br />$URL=$_SERVER['HTTP_REFERER'];<br />$q = "SELECT * FROM counter where url='$URL'";<br />$r = mysql_query($q);<br />$rw = mysql_fetch_array($r, MYSQL_ASSOC);<br />$count = $rw['count'];<br />$dt = date("Y-m-d");<br /><br />if($rw['url'] && $rw['date'] == $dt)<br />$qu = mysql_query("UPDATE counter SET count = '$count + 1' WHERE url='$URL'");<br />else<br />$qu = mysql_query("INSERT INTO counter(url, count, date) VALUES ('$URL', '1', '$dt'"); // first entry <br />?><br /><br />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.<br /><br />Thanks!<br />Mike<!--content-->
Please disregard....<br /><br />the query:<br /><br />$qu = mysql_query("INSERT INTO counter(url, count, date) VALUES ('$URL', '1', '$dt'"); <br /><br />was missing a close paren at the end, should have been.<br /><br />$qu = mysql_query("INSERT INTO counter(url, count, date) VALUES ('$URL', '1', '$dt')"); <br /><br />Thanks!<!--content-->
on your first line<br /><?php><br />you should remove the last charater ><br />it is just <br /><?php<br /><br />Glad you figured it out <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /><!--content-->
<!--quoteo(post=150132:date=Sep 26 2005, 04:03 PM:name=mklappen)--><div class='quotetop'>QUOTE(mklappen @ Sep 26 2005, 04:03 PM) <a href="http://www.totalchoicehosting.com/forums/index.php?act=findpost&pid=150132"><img src='http://www.totalchoicehosting.com/forums/style_images/1/post_snapback.gif' alt='*' border='0' /></a></div><div class='quotemain'><!--quotec-->Hi,<br /><br />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. <br /><br />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?<br />Thanks<br />mk<!--QuoteEnd--></div><!--QuoteEEnd--><br /><br /><br />Have you looked into this <a href="http://proxy2.de/scripts.php" target="_blank">Daily Counter 1.1</a> Then there is a tutorial here <a href="http://proxy2.de/forum/viewtopic.php?t=4121&highlight=daily+counter+modifications" target="_blank">Daily Counter 1.1 modifications</a> for including it into html pages<!--content-->
 
Back
Top