iGuest 3 Report post Posted December 12, 2004 Can anyone tell me how i would go about using PHP & MySQL to count hits on a certain page.ie. someone loads page.php and "1" is added to the value in my mySQL dbthank you Share this post Link to post Share on other sites
iGuest 3 Report post Posted December 13, 2004 assuming you've already connected to the db... <?//EDIT$table = tablename;$id = a unique number or something to define what page you are counting the hits on;//end Edit$hitcount = mysql_query("SELECT hits FROM $table WHERE id = $id LIMIT 1");while($count=mysql_fetch_array($hitcount)) {$hit_count = $count['hits'] + 1;}Print $hit_count;print " people have visited";$update = mysql_query("UPDATE $table SET hits = $hit_count WHERE id='$id'");?> Create a table with the fields id and hits ... you'll have to adjust this...its just a guide Share this post Link to post Share on other sites