Question

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!

Was it helpful?

Solution

Here 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.

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top