Skip to content
Advertisement

Change of td color with php if else statement [closed]

I want to change color of my td as per the date received from the sql query. Please help with following –

I want to change the color of td to green if the fetched date is less than today’s date.

<?php
    if($mydate > date('d-M-Y'))
    {
        echo "<td style="background-color:green;">";
    }
    else
    {
       echo "<td>";
    }
?>

Advertisement

Answer

$mydate = "2015-10-01";
if(strtotime($mydate) > strtotime(date('Y-m-d')))
{
    echo "<td style='background-color:green;'>testing</td>";
}
else
{
   echo "<td>testing</td>";
}
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement