I am trying to alternate the row colors, however I keep getting the following: "Notice: Undefined variable: RowColor in c:\Inetpub\wwwroot\scubamanV2\admin\index.php on line 66" and so on. I have tried many different combinations to no avail. Any help would be gratefully appreciated.
The code:
$the_log = "
<table width=\"100%\" cellpadding=\"2\" cellspacing=\"2\" border=\"0\">
<tr>
<td bgcolor=\"#88C0E0\"><font size=\"1\" face=\"arial\">Date:</font></td>
<td bgcolor=\"#88C0E0\"><font size=\"1\" face=\"arial\">Time:</font></td>
<td bgcolor=\"#88C0E0\"><font size=\"1\" face=\"arial\">Number:</font></td>
<td bgcolor=\"#88C0E0\"><font size=\"1\" face=\"arial\">Site:</font></td>
<td bgcolor=\"#88C0E0\"><font size=\"1\" face=\"arial\">City:</font></td>
<td bgcolor=\"#88C0E0\"><font size=\"1\" face=\"arial\">State:</font></td>
<td bgcolor=\"#88C0E0\"><font size=\"1\" face=\"arial\">Country:</font></td>
<td bgcolor=\"#88C0E0\"><font size=\"1\" face=\"arial\">Photos:</font></td>
</tr> ";
while ($row = mysql_fetch_array($result)) {
$id = $row['id'];
$dive_date = $row['dive_date'];
$dive_time = $row['dive_time'];
$dive_number = $row['dive_number'];
$dive_site = $row['dive_site'];
$dive_city = $row['dive_city'];
$dive_state = $row['dive_state'];
$dive_country = $row['dive_country'];
$dive_buddy = $row['dive_buddy'];
$dive_depth = $row['dive_depth'];
$dive_visibility = $row['dive_visibility'];
$air_temp = $row['air_temp'];
$water_temp = $row['water_temp'];
$weight = $row['weight'];
$the_log .= "<tr>
function useColor()
{
static $ColorValue;
if($ColorValue == \"#FFFFFF\")
{
$ColorValue = \"#C0C0FF\";
}
else
{
$ColorValue = \"#FFFFFF\";
}
return($ColorValue);
}
{
$RowColor = useColor();
<td bgcolor='$RowColor' width='3%'>$dive_date</td>
<td bgcolor='$RowColor' width='3%'>$dive_time</td>
<td bgcolor='$RowColor' width='2%'>$dive_number</td>
<td bgcolor='$RowColor' width='2%'>$dive_site</td>
<td bgcolor='$RowColor' width='2%'>$dive_city</td>
<td bgcolor='$RowColor' width='4%'>$dive_state</td>
<td bgcolor='$RowColor' width='3%'>$dive_country</td>
<td bgcolor='$RowColor' width='2%'><img src=\"images/camera.gif\" border=\"0\" alt=\"View My Pics\"></td>
";
}
$the_log .= "</tr></table>";
print("$the_log");
Thanks
Ivan