While this code seems to work to change $tdstyle as anticipated on the td line, it does not update $font and $text appropriately based on the esleif conditions. It always seems to keep these strings the same based on the else condition alone even if it isn't true. Maybe just a syntax issue? I am certain there is a much better way to do this, but my limited knowledge has brought me to this point. Any suggestions?
<?php
$num = (float)$uvindex;
if($num >10) {
$tdstyle='#B567A4';
$font='white';
$text='Extreme';
} elseif($num >=8) {
$tdstyle='#E53210';
$font='white';
$text='Very High';
} elseif($num >=6) {
$tdstyle='#F18B00';
$font='black';
$text='High';
} elseif($num >=3) {
$tdstyle='#FFF300';
$font='black';
$text='Moderate';
} else $tdstyle='#3EA72D'; $font='black'; $text='Low';
?>
<td height="82" colspan="2" align="center" valign="middle" class="data1" style="text-align:center; background-color:<?php echo $tdstyle ?>; color:<?php echo $font ?>; border: 3px solid black; border-radius: 7px; font-size:12px;">
Aucun commentaire:
Enregistrer un commentaire