Re: Swapping background color

From: Date: Wed, 29 Aug 2001 18:36:17 +0000
Subject: Re: Swapping background color
References: 1 2 3 4 5 6 7 8 9  Groups: php.general 
Request: Send a blank email to php-general+get-65077@lists.php.net to get a copy of this message
In the generated HTML produced by your WHILE statement you can alternate colours. Here's one approach ... the code is bounded by table tags not seen here, the query has been executed and assigned to $result: while( $row = mysql_fetch_array( $result ) ) {
    if( ( $nCounter++ % 2 ) == 0 )
        { echo "<tr bgcolor=\"green\" >"; }
        else
        { echo "<tr bgcolor=\"##CCCC33\" >"; }
    echo "<td>", $row[ no], "</td><td>", $row[ date], "</td><td>", number_format ($row[ yBidAmount ], 2, "," , " " ), "</td></tr>";
} Even rows are green, and odd rows are whatever that other colour is, a deeper green I believe. Now, you may not like my choice of colours, but I was experimenting. The client settled on white and gray. Sigh. Miles At 10:57 AM 8/29/01 -0700, Alnisa Allgood wrote:
I'm not certain if this is more an HTML question or a PHP issue, but... I'm creating an account management system, where each client can have multiple accounts, each account can have multiple users, and each user can make multiple requests. I've created a SQL Query that returns a list of all user requests, based on userID. I'd like to format the display so that it looks like:
(white)  $no   $date     $subject                         $priority $status
(grey)    $no   $date     $subject                         $priority $status
how do I tell php to switch the background color of a row in a table, automatically? Alnisa -- ......................................... Alnisa Allgood Executive Director Nonprofit Tech (ph) 415.337.7412 (fx) 415.337.7927 (url) http://www.nonprofit-techworld.org (url) http://www.nonprofit-tech.org (url) http://www.tech-library.org ......................................... Nonprofit Tech E-Update mailto:nonprofit-tech-subscribe@egroups.com ......................................... applying technology to transform ......................................... -- 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


« previous php.general (#65077) next »