When someone first visits the X page, I insert a new row into the table with the current unix time ().
I want to insert new lines for this user every 24 hours .. so for example:
Example A) Bob, goes to my site, he inserts a line .. 12 hours later, Bob returns, he does not insert a new line, since 24 hours have not passed yet.
Example B) Bob, goes to my site, he inserts a line .. 24 hours later, Bob returns, he inserts a new line within 24 hours, passed.
I deal with this, but I can’t think if it’s right or not because my brain is fried.
$time = time();
$difference = 86400;
$timedifference = $time + $difference;
When inserting a row:
mysql_query("INSERT INTO `logs` (`time`, `who`, `site`, `type`)
VALUES('" . $timedifference . "', '" . $ip . "', '" . $rid . "', 'out') ")
or die(mysql_error());
When checking if it was 24 hours or more:
mysql_query("SELECT * FROM `logs`
WHERE `time` < '" . time() . "' AND `type` = 'out'
AND `site` = '" . $rid . "' AND `who` = '" . $ip . "'");
Can someone please tell me, right?