行的颜色在php桌里

I got table that receives data from database. How can I change color of row when the temperature or humidity is above or under the limits that I get from JSON file. For example: if temperature is higher than minTemp higlight this row green or if temperature is higher than max highlight this row red.

Here is some code:

<?php

$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $pdo->query('SELECT dateandtime, sensor, temperature, humidity FROM temperaturedata ORDER BY dateandtime DESC ');

$tempLimit1 = array();
$fp = fopen('tempLimit.json', 'r');
$bufor = fread($fp, filesize('tempLimit.json'));
fclose($fp);
$tempLimit1 = json_decode($bufor, true);
$minTemp = $templimit1['minTemp'];
$maxTemp = $tempLimit1['maxTemp'];

foreach ($stmt as $row) {
    echo '<tr>';
    echo '<th>' . $row['dateandtime'] . '</th>';
    echo '<th>' . $row['sensor'] . '</th>';
    echo '<th>' . $row['temperature'] . '</th>';
    echo '<th >' . $row['humidity'] . '</th>';
    echo '</tr>';
}
$stmt->closeCursor();

?>

Thank you for all suggestions.

You can use a class and format it with css.

php:

echo "<tr class='green'>
  <td>value1</td>
  <td>value2</td>
</tr>;

css:

.green td {
  background-color: green;
}

You could do this with inline styling like this:

echo '<tr ';
if($row['temperature']>$minTemp){ echo 'style="background-color:green;"'}
echo '>'