COUNTER Code-php Tutorial

Source: Internet
Author: User
Ask for a counter code. you are 4,873rd visitors today. There were 346456 visitors yesterday! & Nbsp; similar to this, you can refresh the values of today plus 1, 2, and 3. it is cleared every night and automatically starts from the beginning. I have found something online and I cannot use it. some of them can use it, but I don't know how to write it in his cont. php. No download is available. Calculate a counter code
You are 4,873rd visitors today. There were 346456 visitors yesterday! Similarly, you can refresh the values of today plus 1, 2, and 3. the values are cleared every night in the early morning and automatically start from the new one. I have found something online and I cannot use it. some of them can use it, but I don't know how to write it in his cont. php. No download is available.

Php? Refresh? Plus one? Code

Share:


------ Solution --------------------

This is a simple database + 1... it's easy to read and write your own books.
------ Solution --------------------
Use session to save user records and write them directly to the database. At a.m., clear the session and record the number of logins on the next day. This is not enough. Did the visitor count yesterday? No. how many visitors are you?
------ Solution --------------------
Reference:
The counter + 1 cannot record the previous day. Is it easy to explain the details on the second floor?


You cannot record yesterday's .... if you need a complete record, you need a detail table. insert each record to the database Time IP address and then display it according to the time stamp when making a statistical display.
------ Solution --------------------
To put it simply, the database creates a memory table clicks with two fields a and UNIQUE B, where field a is used for statistics, and field B represents the zero point of the day.

Php updates with the following SQL statement
Insert into clicks (B, a) VALUES ('On the current day ', 1) ON DUPLICATE KEY UPDATE a = a + 1;

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.