I use a slightly different technique...

Defined in database or global file:
  $tblbgcolor1="FFFFFF";
  $tblbgcolor2="FFFFCC";

Program Loop to create the table:

$altcolor=$tblbgcolor2;
while ($row = mysql_fetch_array($Query)) {
        if ($altcolor==$tblbgcolor2)
                $altcolor=$tblbgcolor1;
        else
                $altcolor=$tblbgcolor2;
        echo "<TR bgcolor='#$altcolor'><TD>Text to
        display on Row</TD></TR>";
}

(this loops through rows fetched from a mysql table, but can be
any kind of loop)

Best regards,
 Randy   


Thursday, January 25, 2001, 3:57:47 PM, you wrote:

BVB> $color = "tan";
BVB> FOR ($i=0 ; $i < $numrows ; $i++) {
BVB>     if ( ($i % 2) == 0 ) {
BVB>       ECHO ("\n<TR>");
BVB>     } else {
BVB>       ECHO ("\n<TR BGCOLOR=$color>");
BVB>     }
BVB> }

>> -----Original Message-----
>> From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]]
>> Sent: Thursday, January 25, 2001 4:19 PM
>> To: Mike
>> Cc: [EMAIL PROTECTED]
>> Subject: Re: [PHP] html table
>> 
>> 
>> > How do I get every other column to be a different color (or 
>> font ect.)when
>> > I'm populating a table from a db(different field counts all the time)
>> 
>> If $i is a counter then $i%2 will alternate between 0 and 1
>> 
>> $i%3 would cycles through 0,1 and 2
>> 
>> -Rasmus
>> 
>> 
>> -- 
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>> 
>> 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to