I have a mysql query as below in my php page,

```
$query = "
select table_date as Date,vals as Value from usertable.table1 group by table_date;";

```

I am fetching data to columns from below method.

```
$result=mysqli_query($conn,$query);
while ($row = $result -> fetch_assoc())
{
    $q2Date .= '<td style="text-align:center"><b>'.$row['Date'].'</td>';
    $q2Value .= '<td style="text-align:center">'.$row['Value'].'</td>';
    $row['Date']++;   
}

```

Then I am using `$body` variable as below to show them in a html table.

```
$body.= '
    <table style="top: 15px; left:10px; " border=1>

        <tbody>
            <caption style="color: rgb(241, 239, 243);background: rgb(1, 32, 65); ">Total Value</caption>
            <tr>
                <td style="text-align:center"><b>Date</td>'.$q2Date  .'
            </tr>
            <tr>
                <td style="text-align:center"><b>Value</td>'.$q2Value .'
            </tr>
        </tbody>
    </table>
';

```

From above method I could get the output as below,

[![enter image description here](https://i.stack.imgur.com/LV1lY.png)](https://i.stack.imgur.com/LV1lY.png)

Now I need to check each cell and change its color if it differs more than 25% from average value(lets say 250). Then the output should show as follows,

[![enter image description here](https://i.stack.imgur.com/YJFkY.png)](https://i.stack.imgur.com/YJFkY.png)

What changes to be done in my original code? Do I need to change my query as well? or HTML or both?