First, a little background on what I have going on here:
In my database I have a table called "tutorials". Each tutorial has its own row in the table.
I have a page called view.php which is the backend of the site, it runs a query and displays a preview of all the tutorials in the database. The preview has a link to the full view of the tutorial, as well as showing the category, date added, and a small description of the tutorial.
What Im trying to do is display the number of unique hits as well. The hit counter you see on the site right now was added by making an extra column in my table called "hits" and using this code:
$sql = "UPDATE tutorials SET hits = hits+1 WHERE id = $id"; mysql_query($sql) or die(mysql_error());This works, but its not a unique counter and updates every time someone even refreshes a page, so as you can imagine it doesnt give a very accurate amount of views.
My question is how would I go about turning this into a unique hit counter? Or limit it so a visitor can only add 1 view per hour or something. Ive seen a hit counter like this on other tutorial/article sites, but just havent been able to figure it out. My only idea is to make another column in the table to store the IP addresses that visit each tutorial, but is it even possible to store multiple IP addresses in a single field? So that I can keep track of which addresses visited which tutorial? I made a unique hit counter before using IP addresses, but it made a new row for every IP and thus could only provide a counter for 1 page per table....not good.
Are there any better methods of going about this that Im overlooking?
Thanks for any help, its much appreciated.