...

View Full Version : Page views with php



Andy92
06-10-2007, 12:43 PM
Hi there,

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?

whizard
06-10-2007, 02:28 PM
Have each page add 1 to a counter for that page in the database when it is loaded

Dan

Andy92
06-10-2007, 02: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?

whizard
06-10-2007, 02: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.

HTH
Dan

Andy92
06-10-2007, 02:45 PM
Ok,

An example i have sene is at...

http://www.johnchow.com/yangmingshan-park-the-worst-ice-cream-in-the-world/

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.

:confused:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum