Home  >  Article  >  php教程  >  php mysql 数据库的页面计数器实例代码

php mysql 数据库的页面计数器实例代码

WBOY
WBOYOriginal
2016-06-02 09:14:201265browse

本款程序是一款简单的实例的php mysql 数据库的页面计数器实例代码,这样你就可以查询你网页访问次数了,实例代码如下:

<HTML> 
<HEAD> 
<TITLE>基于数据库的页面计数器范例</TITLE> 
</HEAD> 
<BODY> 
<?PHP 
 $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=&#39;update num set NumValue=&#39;.$counter.&#39; where id=1&#39;; 
   $result=mysql_db_query("test",$query); 
   //开源代码phprm.com 
   mysql_close(); 
   echo &#39;您好,您是第&#39;. $counter.&#39;位访客&#39;; 
 } 
 
</BODY> 
</HTML>


永久地址:

转载随意~请带上教程地址吧^^

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