Counting the number of unique views of a page
Posted: Mon Aug 15, 2005 6:43 am
Hi There,
I was wondering if anybody could help me to count the amount of unique visitors to a page.
If you take a look at this page:
http://www.thewanderer.co.uk/
You can see that there is a counter for each of the articles. The way in which the count is recorded at the moment is by increasing the number every time the page is viewed, and storing it in a database.
Here is the code that is used:
but if you look at the front page again, you can see that people have been abusing the count by simply refreshing the page over and over.
So I was wondering which is the best way to only count the unique amount of visitors?
Thanks a lot for any help.
I was wondering if anybody could help me to count the amount of unique visitors to a page.
If you take a look at this page:
http://www.thewanderer.co.uk/
You can see that there is a counter for each of the articles. The way in which the count is recorded at the moment is by increasing the number every time the page is viewed, and storing it in a database.
Here is the code that is used:
Code: Select all
//Increment Number of views of the feature.
$a_row = getrow( "features", "id", $id, $link );
$inc = $a_row[views];
$inc++;
$sql = "UPDATE features SET views='$inc' WHERE id='$id'";
$result = mysql_query( $sql, $link );
if ( !$result ){
die( "incr_views error: ".mysql_error() );
}So I was wondering which is the best way to only count the unique amount of visitors?
Thanks a lot for any help.