While I have you reading... Is it possible/how would you go about generating a different background color for cells on a table when displaying your results of a MySql query?
After your query for the records in the search, you have to start a loop to pull out each row. That is your opportunity to keep a $color variable that rotates among a list of N colors and sets the background color of the cell in the table.
Assuming a database table containing two fields (FirstName and LastName), here's a quick snippet to get the idea of what to do. Notice each row alternates the background color of a row (red, green):
<?php
// database connect
// select database
// do your query on the table
//
// now go after each record and print...
// check to make sure there are records to print (else you get an empty useless HTML table)
$numRows = mysql_num_rows($resultFromQuery);
if ($numRows > 0)
{
$i = 0;
echo "<table>";
while($row = mysql_fetch_row($resultFromQuery))
{
if ($i % 2) // alternate on 2 colors. change this algorithm (if needed) to alternate among N colors
$color = "FF0000";
else
$color = "00FF00";
echo "<tr >";
echo "<td bgcolor='" . $color . "'>"
echo $row["FirstName"]
echo "</td>";
echo "<td bgcolor='" . $color . "'>"
echo $row["LastName"];
echo "</td>
echo "</tr>";
++i;
}
echo "</table>";
}
// close database connection
?>