mrjameer Posted June 5, 2007 Share Posted June 5, 2007 hi, i have a mysql table which has 3 fields 1.id 2.username 3.time values 1 abcd 1181027044 i want to fetch only those user id's and usernames whos time is equal to current date.any of your idea will be surely appreciated. thanks mrjameer Quote Link to comment https://forums.phpfreaks.com/topic/54250-comparing-the-todays-date-with-timestamp-value/ Share on other sites More sharing options...
Lumio Posted June 5, 2007 Share Posted June 5, 2007 <?php $today = strtotime('today'); $sql = "SELECT `id`, `username` FROM `table` WHERE `time` >= $today"; $res = mysql_query($sql); if ($res) { while($row = mysql_fetch_assoc($res)) { echo $row['username']."<br />\n"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/54250-comparing-the-todays-date-with-timestamp-value/#findComment-268233 Share on other sites More sharing options...
mrjameer Posted June 5, 2007 Author Share Posted June 5, 2007 hi, thanks for your reply.i have tested the code but nothing is displaying thanks mrjameer Quote Link to comment https://forums.phpfreaks.com/topic/54250-comparing-the-todays-date-with-timestamp-value/#findComment-268429 Share on other sites More sharing options...
Lumio Posted June 5, 2007 Share Posted June 5, 2007 maybe this works: <?php $today = strtotime('today'); $sql = "SELECT `id`, `username` FROM `table` WHERE `time` >= $today"; $res = mysql_query($sql); if (!($err = mysql_error())) { while($row = mysql_fetch_assoc($res)) { echo $row['username']."<br />\n"; } }else echo $err; ?> Quote Link to comment https://forums.phpfreaks.com/topic/54250-comparing-the-todays-date-with-timestamp-value/#findComment-268592 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.