View Full Version : Page views with php
06-10-2007, 11:43 AM
Basically on my blog, i want it to say at the bottom of each post how many page views it has.
How can i do this?
06-10-2007, 01:28 PM
Have each page add 1 to a counter for that page in the database when it is loaded
06-10-2007, 01:32 PM
Yes, thats a good idea, but people could just keep refreshing the page and it would add 1 to the counter for that page.
How can i prevent this?
06-10-2007, 01:39 PM
Well.. maybe if there is a new IP address add one to the database? Or use session variables to determine which pages have been viewed already?
Beyond that, it seems to me that even if its just a refresh, it is a page view, so if that is what you are trying to count, thats what will be counted.
06-10-2007, 01:45 PM
An example i have sene is at...
Have a look just before the comments at the bottom of the post. It says...
Posted in Ramblings (http://www.johnchow.com/category/uncategorized/) | | 3,840 Views | Random Post (http://www.johnchow.com/?random)
How do you think that they count their views on the john chow blog?
Do you think that they log each persons ip address for 1 hour, so that if they keep refreshing the page it wont count the page view, and then after the hour if they refresh the page it will add another page view.
So basically, each person is only allowed to have 1 page view per hour on the same page.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.