I have a php/mysql/html table of results

The query is

$result = mysql_query('
Select 
var1,
sum(var2) 
round(Avg(var3),0)
round(Min(Price),2), 
round(Max(Price),2), 
round(Avg(Price),2) as AvgPrice, 
Country,
From table
Where country = "Australia"
Group By var1
having var3 > 5
Order By var3 DESC') 
or die("SELECT Error: ".mysql_error()); 
$num_rows = mysql_num_rows($result); 
print "<table width=800 border=1>\n"; 
echo "<tr> <th>Var1</th> <th>Sum(Var2)</th> <th>Avg Var4</th> <th>£ Min</th> <th>£ Max</th> <th>£ Average</th> <th>Country</th> </tr>";
while ($get_info = mysql_fetch_row($result)){ 
print "<tr>\n"; 
foreach ($get_info as $field) 
print "\t<td><font face=arial size=2/>$field</font></td>\n"; 
print "</tr>\n"; 
} 
print "</table>\n";

What I want to do is to highlight a cell where an individual result is out of 'tolerance'. For example the minimum price is too low or another variable is out of a range.

I think it can be done with CSS but could someone give me a starter?

Member Avatar for diafol
<head>
 <style>td.highlight: background-color: yellow;</style>
</head>

...
<?php
$value1 = 4; 
$value1_tol = 1; (allows values 3 - 5);


$min_value1 = $value1 - $value1_tol;
$max_value1 = $value1 + $value1_tol;


...loop...
$class = ($field > $max_value1 || $field < $min_value1) ? ' class="highlight"' : '';
...
print "\t<td$class>field</td>\n"; 
...
...end loop...
...
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.