Counters and their applications: Three steps to DIY a counter

WBOY
Release: 2016-07-29 08:33:18
Original
1266 people have browsed it

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 pictures 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.
                                              

The above has introduced the counter and its application. The three steps of DIY counter creation include the counter and its application. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!