Home  >  Article  >  Backend Development  >  Three Steps to Building a Counter DIY (Part 1)_PHP Tutorial

Three Steps to Building a Counter DIY (Part 1)_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 16:05:53750browse

Most people are eager to use databases to make their own counters, guestbooks, forums, and the like. This article will introduce my self-made counter program.
First create 10 GIF digital images from 0 to 9, place them in the img folder, and then create a PHP file
——count1.php. The procedure is as follows:
$linkptr =mysql_pconnect("localhost","yourname","password");

mysql_select_db("yourname",$linkptr);
mysql_query("update counter
set visited=visited+1 where num=1",$linkptr);
$result=mysql_query("select visited
from counter where num=1",$linkptr);
list($counter)=mysql_fetch_row($result);
$counter=sprintf("%05d",$counter);

for($i=0;$i<5;$i++){
$tmpstr="";
echo $tmpstr;
}
?>
Place the code at the appropriate location on the homepage , so that your counter will be displayed on the homepage, but remember to create a TABLE on your database - counter:create table counter(
num int unsigned,
visited int unsigned
);
How about it, easy! In the second part, I will introduce how to make your mirror site use your own counter.
                                     

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/315580.htmlTechArticleMost people are eager to use databases to make their own counters, guestbooks, forums and the like. This book This article will introduce my self-made counter program. First create 10 GIF numbers from 0 to 9...
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