Page 1 of 1

PHP filter by Date

Posted: Mon Nov 02, 2009 9:34 am
by koolsamule
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:

Code: Select all

<?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?

Re: PHP filter by Date

Posted: Mon Nov 02, 2009 9:43 am
by s1auk14

Re: PHP filter by Date

Posted: Mon Nov 02, 2009 9:44 am
by Eric!
Why not let sql do the work? Just make a query that returns the overdue projects. That's what databases are good for. Otherwise you have to play some games with the date format to compare them in php.

Re: PHP filter by Date

Posted: Mon Nov 02, 2009 9:58 am
by koolsamule
I can't have multiple queries, as I need the results to be presented in one table.
There are 3 style states, overdue, duetoday and within, this would mean I have 3 tables instead of one....doesn't it?