I have this code and I want it to add a row if a user has not been on the site within the last 30 mins it adds a new row...
but what if there are 10 rows with the same IP..... i want to selected the latest row with this IP!!
$newIP = $_SERVER['REMOTE_ADDR'];
$self = $_SERVER['PHP_SELF'];
$time2 = time();
$host = $_SERVER['HTTP_USER_AGENT'];
$ref = $_SERVER['HTTP_REFERER'];
$result = mysql_query ("SELECT * from counter where IP = '$newIP'");
$row = mysql_fetch_array($result);
$timestamp = $row["timestamp"];
$IP = $row["IP"];
if ($timestamp >= time() - 1800)
{
echo '';
exit();
} else {
$result2 = mysql_query ("INSERT INTO counter (`id`,`IP`,`page`,`visit_date`,`visit_time`,`timestamp`,`host`,`ref`) Values ('','$newIP','$self','$date','$time','$time2','$host','$ref')") or die("INSERT error: ".mysql_error());
}
Does anyone see any other errors they want to point out?