Create counter DIY three-step (top) _php Foundation

Source: Internet
Author: User
Most people are very yearning to use the database to do their own counters, messages, forums and things like this, this article will introduce my own self-made counter program.
First set up 0~9 these 10 gif digital pictures, put 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 in the appropriate place on the home page. Include "count1.php" so that your counter is displayed on the home page, but remember to create a table--counter:create table counter on your database (
num int unsigned,
visited int unsigned
);
How easy it is! Medium I will show you how to get your mirror station to use your own counters as well.
                                                        

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.