I want to change td color using if statement but somehow my code is not affecting all rows
-
this is my code :
require_once("../model/materiel.class.php" . ""); $mt=new materiel(); $data=$mt->afficher_tous1(); echo '<table id="customers2" class="table datatable table-striped">'; echo "<thead> <tr> <th>Qte disponible</th> <th>Alert</th> </tr> </thead>"; echo "<tbody>"; foreach($data as $t){ echo "<tr>"; if ($t['qte_disponible_m'] == 0){ echo "<td bgcolor='red'>".$t['qte_disponible_m']."</td>"; }else if ($t['qte_disponible_m'] > $t['alert_m']){ echo "<td bgcolor='green'>".$t['qte_disponible_m']."</td>"; }else if ($t['qte_disponible_m'] == $t['alert_m']){ echo "<td bgcolor='yellow'>".$t['qte_disponible_m']."</td>"; } echo "<td>".$t['alert_m']."</td>"; echo "</tr>"; } echo "</tbody>"; echo"</table>";
- the problem i have see the screenshot below :
If statement is like jumping next row