jeff5656 Posted April 25, 2008 Share Posted April 25, 2008 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> Quote Link to comment https://forums.phpfreaks.com/topic/102933-solved-comparing-dates/ Share on other sites More sharing options...
p2grace Posted April 25, 2008 Share Posted April 25, 2008 What's the date format? If the date format isn't a number then php can't determine what's greater than the other. Quote Link to comment https://forums.phpfreaks.com/topic/102933-solved-comparing-dates/#findComment-527330 Share on other sites More sharing options...
jeff5656 Posted April 25, 2008 Author Share Posted April 25, 2008 Never mind. Actually it does work. I was putting in all my test dates as earlier than today sop it was (correctly) making background red). duuuhh... Quote Link to comment https://forums.phpfreaks.com/topic/102933-solved-comparing-dates/#findComment-527338 Share on other sites More sharing options...
p2grace Posted April 25, 2008 Share Posted April 25, 2008 lol cool Could you mark the topic as solved when you get a chance Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/102933-solved-comparing-dates/#findComment-527341 Share on other sites More sharing options...
ucffool Posted April 25, 2008 Share Posted April 25, 2008 Two things: 1) What is the format of 'check_date2' ? 2) change this line to: if ($whencheck < time()) my guess is that #1 is not giving the date and time, just date (causing you issues). Quote Link to comment https://forums.phpfreaks.com/topic/102933-solved-comparing-dates/#findComment-527344 Share on other sites More sharing options...
p2grace Posted April 25, 2008 Share Posted April 25, 2008 He already said it was working Quote Link to comment https://forums.phpfreaks.com/topic/102933-solved-comparing-dates/#findComment-527348 Share on other sites More sharing options...
ucffool Posted April 25, 2008 Share Posted April 25, 2008 Reading too many threads at once, my bad. <prepares to be caned> Quote Link to comment https://forums.phpfreaks.com/topic/102933-solved-comparing-dates/#findComment-527353 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.