kool_samule Posted November 2, 2009 Share Posted November 2, 2009 Hi Chaps, I have a bit of PHP code, that at the moment doesn't work. I'm trying to show all the 'overdue' projects in a different style: <?php if ($row_rsProjects['projdue'] == '= DATE(NOW())') { ?> <tr class="overdue"> <?php } else if ($row_rsProjects['projdue'] == '< DATE(NOW())') { ?> <tr class="duetoday"> <?php } else { ?> <tr class="within"> <?php }?> The '= DATE(NOW())' works with MySQL, but I don't know how to get it to work with PHP. Any ideas? Quote Link to comment Share on other sites More sharing options...
pastcow Posted November 2, 2009 Share Posted November 2, 2009 if ($row_rsProjects['projdue'] == DATE("Y-m-d") should give you the same functionality you might want to check http://php.net/manual/en/function.date.php for more info... Quote Link to comment Share on other sites More sharing options...
kool_samule Posted November 2, 2009 Author Share Posted November 2, 2009 This is what I've got so far, <?php $today = date("dd/mm/yyyy"); if ($row_rsProjects['projdue_format'] == $today) { ?> <tr class="duetoday"> <?php } else if ($row_rsProjects['projdue_format'] < $today) { ?> <tr class="overdue"> <?php } else if ($row_rsProjects['projdue_format'] > $today) { ?> <tr class="within"> <?php }?> But still isn't working correctly, projects with today's date are showing up as 'overdue' Quote Link to comment Share on other sites More sharing options...
pastcow Posted November 2, 2009 Share Posted November 2, 2009 $today = date("dd/mm/yyyy"); gives the output 0202/1111/09090909 - you need to make sure you have your date format correct. $today = date("Y-m-d"); will give you 2009-11-02 which is probably what you want to be compatable with mysql. A much better way of doing this would be to use Unix timestamps that are integers. this makes > < and == much simpler. Quote Link to comment 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.