I've just tested this stripped down (some colours changed) version of your
code and I get alternating rows no problem. On another point, without the
<TABLE> tags it won't work properly. I think your PHP works fine, it's your
HTML ;o)

Nick

<?php
$cols = array('#ff0000','#00ff00');
print "<TABLE>";
for ($i = 0; $i<10;) {
print '<tr bgcolor="'.$cols[$i++%2].'">';
print "<td width=\"12%\" align=\"center\" height=\"6\"><font face=\"Tahoma\"
size=\"2\" color=\"555555\">TEST</font>" ;
print "&nbsp;</td></tr>";
}
print "</TABLE>";
?>





-----Original Message-----
From: Denis L. Menezes [mailto:[EMAIL PROTECTED]]
Sent: 17 January 2003 12:12
To: PHP general list
Subject: [PHP] Alternate row colours - what is wrong with this code?


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


This private and confidential e-mail has been sent to you by Egg.
The Egg group of companies includes Egg Banking plc
(registered no. 2999842), Egg Financial Products Ltd (registered
no. 3319027) and Egg Investments Ltd (registered no. 3403963) which
carries out investment business on behalf of Egg and is regulated
by the Financial Services Authority.  
Registered in England and Wales. Registered offices: 1 Waterhouse Square,
138-142 Holborn, London EC1N 2NA.
If you are not the intended recipient of this e-mail and have
received it in error, please notify the sender by replying with
'received in error' as the subject and then delete it from your
mailbox.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to