Re: html table
| From: | Randy | Date: | Thu, 25 Jan 2001 22:32:04 +0000 |
| Subject: | Re: html table | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-36715@lists.php.net to get a copy of this message | ||
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:rasmus@php.net]
>> Sent: Thursday, January 25, 2001 4:19 PM
>> To: Mike
>> Cc: php-general@lists.php.net
>> 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: php-general-unsubscribe@lists.php.net
>> For additional commands, e-mail: php-general-help@lists.php.net
>> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>>
>>