0

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!

  • 1
    You can ask this question at stackoverflow.com this site is particularly for WordPress development related questions. Thanks! – jas Dec 9 '15 at 10:20
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.