SQL报告颜色

we have following sql code for report agent database..

<?php
$sql=mysql_query("SELECT Name, sum( Points )AS Total_Points
FROM`allagentper`
GROUP BY Name
ORDER BY Points DESC ");
print"<table >";
print"<tr><th>Name</th><th>Points</th></tr>";
while($row=mysql_fetch_assoc($sql))
{
print"<tr>";
foreach($row as $value)
{

print"<td>";
echo $value ;
print "</td>";
}

print"</tr>";

}

print"</table>";


mysql_close($con);



?>

The end report shown as following type:

Name  points
abc     78
dks     65
sge     64
sdf     62    <= Blue
ssr     62    <= Blue
eew     60    <= Blue
asw     60    <= Blue

I need to colorize row table for every 3 rows in sql. first 3 rows will be red. second 3 row will blue. but the condition is if points are same, it should should take same color only.. if you see the above report example, sdf, ssr, eew are blue color. but asw also same point as eew so then it should be blue color for last 4 rows.

I would do something like this

<?php
$sql=mysql_query("SELECT name, sum( Points )AS total_points
FROM`allagentper`
GROUP BY Name
ORDER BY Points DESC ");
print"<table >";
print"<tr><th>Name</th><th>Points</th></tr>";
$rowCounter = 0;
$previousTotal = -9999999;
while($row=mysql_fetch_assoc($sql))
{

if($rowCounter % 6 > 3)
{
$color = "#FF0000";
}
else
{
$color = "#0000FF";
}

print"<tr>";
print"<td>".$row->name."</td>";
print"<td style='color:".$color."'>".$row->total_points."</td>";
print"</tr>";

if($row->total_points != $previousTotal)
{
rowCounter++;
}
$previousTotal = $row->total_points;
}

print"</table>";
mysql_close($con);
?>