Home >php教程 >PHP源码 >基于数据库的页面计数器范例

基于数据库的页面计数器范例

WBOY
WBOYOriginal
2016-06-08 17:30:031044browse

基于数据库的页面计数器范例

<script>ec(2);</script>




 $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.'位访客';
 }
 
?>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn