I have a table with which stores the last login time of users in UNIX format. I want to get the information about all those users who logged in at least 4 days ago. This is an image of the database:
I have tried this:
$time = sql_query("select * from ".tb()."accounts");
$pp = sql_fetch_array($time);
$tp = $pp['lastlogin'];
$ts = strtotime('-4 day',time());
$tg = $tp > $ts;
$res = sql_query("select f.fid from ".tb()."friends as f left join ".tb()."accounts as u on u.id=f.fid where f.uid='{$client['id']}' order by {$tg} desc limit 50");
but it does not seem to be working. Is there an easy wayto display the info of all those users who lo开发者_如何学JAVAgged in more than 4 days ago?
Select rows where the last login is more than 4 days in the past:
SELECT
...
WHERE
FROM_UNIXTIME(lastlogin) < CURRENT_TIMESTAMP - INTERVAL 4 DAY
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html
精彩评论