jeff5656 Posted December 1, 2008 Share Posted December 1, 2008 This array echoes which_date <td>. The values range from 1 to 31 and all in between. How do I modify this to say: if the current value equals today's date (i.e. "1" if it's 12/1/08), then make the bgcolor red fo that <td>? <table >"; $varArray = array("which_date"); $varArraySize = count($varArray); for ($i = 0; $i < $varArraySize;$i++) { for ($f = 1; $f < 32; $f++) { echo "<td style='border-bottom-style: solid;'> " . $row[$varArray[$i] . $f] . "</td>"; echo "<tr>"; } } echo "</table> Link to comment https://forums.phpfreaks.com/topic/135026-change-bgcolor-based-on-value/ Share on other sites More sharing options...
Lumio Posted December 1, 2008 Share Posted December 1, 2008 <?php $currentDay = intval(date('j')); //Current day $days = intval(date('t')); //How many days has the current month for ($iDay=1; $iDay <= $days; $iDay++) { if ($iDay == $currentDay) echo '<b style="color:red;">'.$iDay.'</b>'; else echo $iDay; } ?> Link to comment https://forums.phpfreaks.com/topic/135026-change-bgcolor-based-on-value/#findComment-703271 Share on other sites More sharing options...
jeff5656 Posted December 1, 2008 Author Share Posted December 1, 2008 Sorry I'm really bad with understanding arrays - how do I put your code into my own code? My own code has variables like 1, 2, etc up to 31 but they are NOT recognized as dates of the month, inly absolute values. Link to comment https://forums.phpfreaks.com/topic/135026-change-bgcolor-based-on-value/#findComment-703292 Share on other sites More sharing options...
jeff5656 Posted December 1, 2008 Author Share Posted December 1, 2008 Anyone? Link to comment https://forums.phpfreaks.com/topic/135026-change-bgcolor-based-on-value/#findComment-703488 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.