Change colour of table td based on value

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.