I am writing a little function to record the visits to a landing page, and want to do it in such a way as to not count multiple visits from the same IP address within a 24 hour period.
What I was wondering is if there is a way to do a conditional insert based on the IP address not having a matching record with the visit_date less than 24 hours old. So it would cover whether there was a record with that IP or not.
Here is the basic structure I think will work, but I need some direction in the area of the " now ( ) - 24 hour " part... I know that syntax isn't correct, but just put it there to show my thought process.
any assistance would be greatly appreciated.
$visitor_ip=$_SERVER['REMOTE_ADDR']; $sql_i = " INSERT INTO lead_visit(visit_id, mem_id, page_name, visit_date, visit_ip) VALUES('', '$mem_id', '$page_name', now(), '$visitor_ip') WHERE ((select count(*) from lead_visit where visit_date>(now()-24 hours)) = 0) ";