Home  >  Article  >  Backend Development  >  PHP mysql database page counter example code_PHP tutorial

PHP mysql database page counter example code_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:04:17962browse

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.


Database-based page counter example

$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';
}

?>


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/630868.htmlTechArticleThis program is a simple example code of page counter of php mysql database, so that you can query The number of visits to your web page. This program is a simple example...
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