Reputation: 5105
So I finally have a SQL query working to take 3 conditions from my DB table and set a flag based on them.
Here is the Statement:
UPDATE staging
SET `miuFlag` =1
WHERE `lowSideMIUNumArriv` = `lowSideMIUNumDepart`
AND `miu` = "No"
Now my database table has a column called 'miuFlag' with either ones or zeroes. Based on this value, I want one of my html table values to be red or green (0=red, 1=green).
Here is the affected html table row:
<td><? echo $row['miu'];?> </td>
I know I can color this row's font by using style inside of the td element, but how exactly would I create the condition to style one color for miuFlag = 0 and another for miuFlag = 1?
Upvotes: 0
Views: 549
Reputation: 85
I think it would be something like this:
<td class="<? echo ($row['miu'] == 0) ? "redstyle" : "greenstyle"); ?>"> </td>
Upvotes: 1
Reputation: 273
You can try this code:
<td styel="<?php $row[miuFlag] == 1 ? 'color:green' : 'color:red' ?>"><?= $row['miu'];?> <td>
Upvotes: 1
Reputation: 282
HTML:
<td class="<?php echo (int)$row['miu']?'red':''?>"><? echo $row['miu'];?> </td>
CSS
.red{
color:red;
}
Upvotes: 1