I have a reports table where i count hits by just using the code below.
// Get hits
$hits_query = mysql_query("SELECT COUNT(*) AS `count` FROM `reports` WHERE `stuff_id` = ".$row->id."");
$fetch_hits = mysql_fetch_array($hits_query);
$hits = $fetch_hits['count'];
That code works great and does exactly what i want but what i want now is how to get unique hits?
In my reports table i store every access so theres multiple log for each user base on the stuff_id . In my reports table I store the date as 01-23-2013 on each report, along with the user ip and stuffed which every 24 hours change from 2 to 1.
You need a field that uniquely identifies the user. I am going to assume for my example that it is
user_ip. Change this:To this:
NOTE: mysql library will be deprecated as of PHP 5.5 and removed in future versions of PHP. It would be a good idea to start planning a migration away from it.