I have this code in my table calling in a number
<tr>
<td>Total: <?php echo $total_credit;?></td>
</tr>
I would like to change the background colour or the text colour depending on whether this value is equal to or higher than 2, is there an easy way I could do this with an If statement?
Thanks for any help in advance!
I have this code in my table calling in a number
<tr>
<td>Total: <?php echo $total_credit;?></td>
</tr>
I would like to change the background colour or the text colour depending on whether this value is equal to or higher than 2, is there an easy way I could do this with an If statement?
Thanks for any help in advance!
Share Improve this question asked Dec 9, 2015 at 10:15 Lucy BrownLucy Brown 1491 gold badge3 silver badges11 bronze badges 1- 1 You can ask this question at stackoverflow this site is particularly for WordPress development related questions. Thanks! – jas Commented Dec 9, 2015 at 10:20
1 Answer
Reset to default 0Here is the updated code with condition
<tr>
<td <?php if($total_credit >= 2): ?> style="background-color:#000000;" <?php endif; ?>>
Total: <?php echo $total_credit;?>
</td>
</tr>
Change #000000 to appropriate color code. Then the background color will be changed. Use same logic for changing the text color.