PHP filter by Date

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
koolsamule
Forum Contributor
Posts: 130
Joined: Fri Sep 25, 2009 10:03 am

PHP filter by Date

Post 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?
s1auk14
Forum Newbie
Posts: 15
Joined: Mon Nov 02, 2009 8:29 am

Re: PHP filter by Date

Post by s1auk14 »

Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: PHP filter by Date

Post 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.
koolsamule
Forum Contributor
Posts: 130
Joined: Fri Sep 25, 2009 10:03 am

Re: PHP filter by Date

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