Home > Article > Backend Development > PHP mysql database page counter example code_PHP tutorial
This program is a simple example code of page counter for php mysql database, so that you can query the number of visits to your web page.
This program is a simple example PHP tutorial mysql tutorial database tutorial Page counter example code, so that you can query the number of visits to your web page.
$db=mysql_connect("localhost","root","qwaszx");
$query="select * from num";
$result=mysql_db_query("test",$query);
if($result){
$r=mysql_fetch_array($result);
$counter=$r["NumValue"];
$counter=$counter+1;$query='update num set NumValue='.$counter.' where id=1';
$result=mysql_db_query("test",$query);
mysql_close();
echo 'Hello, you are the '.$counter.' visitor';
}
?>