Table Problems *Solved*
Posted: Tue Apr 12, 2005 9:35 am
can anyone see why my alternating colors are not appearing in my table
Code: Select all
// Query to extract records from database.
$result = mysql_query ("$query LIMIT $limit") or die ("Error in query: $result".mysql_error());
// Define your colors for the alternating rows
$color1 = "0099FF";$color2 = "0000FF";
$color = $color2;
echo "<table width=\"50%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\">
<tr>
<td> <b>Record<b> </td>
<td> <b>Id</b> </td>
<td <b>Name</b> </td>
<td> <b>Organisation</b> </td>
<td> <b>Website</small></b> </td></tr>";
while ($row = mysql_fetch_object($result))
{($color==$color2)? $color = $color1 : $color = $color2;
echo "<tr bgcolor=\"$color\"><td>".$count . '</td>
<td>'.$row->stu_id.'</td>
<td>'.$row->name.'</td>
<td>'. $row->organisation .'</td>
<td>'. $row->website .'</tr>';
$count += 1;
}
echo "</table>";