I'm having trouble getting my query statement to work. Everytime someone logs into my site, I record their info (including date and time separately) into a mysql database. I'm now building a page that shows all the people that have logged in within the past 10 minutes.
I can select people who's login date is less than 1 day ago, but the login time part doesn't work.
Code: Select all
<?php
$query = "SELECT * from members WHERE LoginDate <= DATE_SUB(CURDATE(), INTERVAL 1 DAY) AND LoginTime <= DATE_SUB(CURTIME(), INTERVAL 10 MINUTE)";
?>
It seems to work for the date part when I remove the code for the time part. But, I want to only show people who have logged in within the last 10 minutes.
LoginDate is in a date field as YYYY-MM-DD and LoginTime is in a time field as HH:MM:SS.
Any help would be greatly appreciated.