Jump to content

[SOLVED] comparing dates


jeff5656

Recommended Posts

I want the background color of a cell to be red if the date is today or later.

 

However, ALL of them have a red background, even if the date is earlier.

If I change the > to a < then NONE of the dates are red.

 

any ideas?

 

$curr_date = date ("Y-m-d");
$today = strtotime ($curr_date);


$query = "SELECT * FROM `reminders` WHERE `done_status` = 'a' AND `physician` = '". $physician ."' ORDER BY `check_date2` ";

$results = mysql_query ($query) or die (mysql_error());
$num_pts = mysql_num_rows ($results);

$consultheading =<<<EOD


<table  bgcolor="#CCCCFF" width = "98%" border = "1" cellpadding = "2"
cellspacing = "2" align = "center">

<th> Name <i>(Click to edit)</i></th>
<th> MRN </th>
<th> Physician </th>
<th> Date entered</th>
<th> To Check </th>
<th> Date to check  </th>
<th> Action taken to date </th>
</tr>
EOD;
echo $consultheading;

while ($row = mysql_fetch_assoc ($results)) {
?>
<tr>
  <td bgcolor="#FFFFFF" ><a href="editptform_reminders.php?action=edit&id=<?php
 echo $row['id_incr']; ?>">
  <?php echo $row['patient_name'];?></a></td>
    <td bgcolor="#FFFFFF" >
  <?php echo $row['mrn'];?> </td>
    <td bgcolor="#FFFFFF" ><font size="1">
  <?php echo $row['physician'];?></font> </td>
    <td bgcolor="#FFFFFF" >
  <?php echo $row['rcf_date'];?> </td>
    <td bgcolor="#FFFFFF" >
  <?php echo $row['to_check'];?> </td>
  <td <?php 
  
  $whencheck = strtotime ($row['check_date2']);
  
  if ($whencheck < $today) 
  {
   echo "bgcolor='#FF0033'";
   }
   else {
   echo "bgcolor='#FFFFFF'";
   }
   ?>
   >
      
  <?php
  echo $row['check_date2'];?> </td>
    <td bgcolor="#FFFFFF" >
  <?php echo $row['action_taken'];?> </td>
        
</tr>
      <?php
     }
     ?>
     
<td bgcolor="#CCCCCC" colspan=7 align="center" class="fineprint"> Total Reminders: 
<?php echo $num_pts; ?></td></tr>

Link to comment
https://forums.phpfreaks.com/topic/102933-solved-comparing-dates/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.