colorer <tr> d’après variable php
Bonjour,
j'ai un tableau en deux colonnes qui m'affiche un nom et un nombre pour la deuxième colonne issu d'une requête sql.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| <table border="1">
<tr>
<td></td>
<td>Nom</td>
<td width="80"><div align="center">etat</div></td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_Recordset_cdg_nv['Nom']; ?></td>
<td width="80" ><div align="center"><?php echo ceil(($row_Recordset_cdg_nv['pourcent']*100)/$etat_4); ?> % </div></td>
</tr>
<?php } while ($row_Recordset_cdg_nv = mysql_fetch_assoc($Recordset_cdg_nv)); ?>
</table> |
et je voudrais que si ma valeur
Code:
ceil(($row_Recordset_cdg_nv['pourcent']*100)/$etat_4)
est < à 50 colorer la ligne concerné en orange et si elle est > à 50 en vert.
j'ai tenté ceci mais ça ne fonctionne pas :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| <table border="1">
<tr>
<td></td>
<td width="80"><div align="center">etat</div></td>
</tr>
<?php do { ?>
<?php $pourcentage = ceil(($row_Recordset_cdg_nv['pourcent']*100)/$etat_4);
if ($pourcentage == 0) { ?>
<tr bgcolor="#FF0000">
<?php }; ?>
<?php else ($pourcentage < 49) { ?>
<tr bgcolor="#FF6600">
<?php }; ?>
<?php else ($pourcentage > 49) { ?>
<tr bgcolor="#3399CC">
<?php }; ?>
<?php else($pourcentage == 100) { ?>
<tr bgcolor="#009900">
<?php }; ?>
<td><?php echo $row_Recordset_cdg_nv['Nom']; ?></td>
<td width="80" ><div align="center"><?php echo ceil(($row_Recordset_cdg_nv['pourcent']*100)/$etat_4); ?> % </div></td>
</tr>
<?php } while ($row_Recordset_cdg_nv = mysql_fetch_assoc($Recordset_cdg_nv)); ?>
</table> |