Alternate row colours - what is wrong with this code?

From: Date: Fri, 17 Jan 2003 12:11:57 +0000
Subject: Alternate row colours - what is wrong with this code?
Groups: php.general 
Request: Send a blank email to php-general+get-131987@lists.php.net to get a copy of this message
Hello Guys, I want alternating colours in the output table. Can someone tell me what is wrong with this code? I get the data but no alternating colours. Quote : <?php $cols = array('#ff0000','#00ff00'); $i = 0; while($row=mysql_fetch_array($result)){ echo '<tr bgcolor="'.$cols[$i++%2].'">'; Print "<td width=\"12%\" align=\"center\" height=\"6\" bgcolor=\"#FFFFbf\"><font face=\"Tahoma\" color=\"#000000\">" ; Print "<b> <font size=\"2\" color=\"ff0000\"> $row[OrgName] </b></font>"; print "</font> &nbsp;</td>"; Print "<td width=\"12%\" align=\"center\" height=\"6\" bgcolor=\"#FFFFbf\"><font size=\"2\" face=\"Tahoma\" color=\"#000000\">" ; Print $row[Country]; print "</font> &nbsp;</td>"; Print "<td width=\"12%\" align=\"center\" height=\"6\" bgcolor=\"#FFFFbf\"><font size=\"2\" face=\"Tahoma\" color=\"#000000\">" ; Print $row[Date]; print "</font> &nbsp;</td>"; Print "<td width=\"12%\" align=\"center\" height=\"6\" bgcolor=\"#FFFFbf\"><font size=\"2\" face=\"Tahoma\" color=\"#000000\">" ; Print $row[Number]; print "</font> &nbsp;</td>"; Print "<td width=\"12%\" align=\"center\" height=\"6\" bgcolor=\"#b7b700\"><font size=\"2\" face=\"Tahoma\" color=\"#000000\">" ; Print "<form action=\"fullmarks.php\" method=\"post\">"; Print"<INPUT TYPE=\"submit\" value=\"View details\" Name=\"Details\">"; Print"<input type=\"hidden\" name=\"SelectedItemNumber\" value= $row[Id]"; print "</td>"; Print "</form>"; Print "</tr>";} } ?> Unquote. Thanks Denis

« previous php.general (#131987) next »