Version: 1.2
Type: Full Script
Category: Databases
License: GNU General Public License
Description: MAYBE NOT THE OBVIOUS WAY TO GET THERE BUT ONLY TAKES FIVE MINUTES TO GET GOING.
<? ////////////////////////////////////////////////////////////////////////// /// VERY ROUGH BUT SIMPLE PHP/MYSQL HIT COUNTER /// MAKE A MYSQL TABLE CALLED VISITORS WITH TWO FIELDS - COUNT AND CLASS /// INSERT ONE RECORD WITH COUNT BEING 0 AND CLASS BEING PUBLIC /// DRUCIFER 2003 - [email protected] /// GNU General Public Licence /// Version 1.2 ////////////////////////////////////////////////////////////////////////// session_start(); /// CHECK IF VISITOR HAS ALREADY BEEN COUNTED IF ($count_visitor!="") { /// DON'T COUNT VISITOR TWICE IN SAME SESSION $count=mysql_query("SELECT count FROM visitors LIMIT 1", $YOURDATABASE); $rows=mysql_fetch_array($count); $newcount= $count_visitor; } ELSE { /// COUNT VISITOR AND ADD TO MYSQL COUNTER TABLE $count=mysql_query("SELECT count FROM visitors LIMIT 1", $YOURDATABASE); $rows=mysql_fetch_array($count); $newcount= mysql_result($count,0,"count")+1; $addvisitor = "UPDATE visitors SET count='$newcount' WHERE class='public'"; $result = MYSQL_QUERY($addvisitor); $count_visitor= 'newcount'; session_register("count_visitor"); } /// OUTPUT VISITOR NUMBER PRINTF ("YOU ARE VISITOR NUMBER: $newcount"); ?>