基于数据库的页面计数器范例
$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 '您好,您是第'. $counter.'位访客';
}
?>