Jump to content

Change bgcolor based on value


jeff5656

Recommended Posts

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

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

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.