RE: [PHP] Returning Rows Question

From: Date: Wed, 04 Sep 2002 23:26:52 +0000
Subject: RE: [PHP] Returning Rows Question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-115250@lists.php.net to get a copy of this message
> How do you alternate colors of the rows in a table inside a > while statement > when dealing with the output of data from a DB. I am sure > it's something > simple but I keep getting into some really long math thing... For two alternating colours I normally do something like this: $use_col = "#00FF00"; While (some = condition) { echo "using $use_col"; if ($use_col == "#00FF00") { $use_col = "#0000FF"; } else { $use_col = "#00FF00"; } } Basically, set a colour to use, then in your while loop you see if it is one of the colour, if it is change it to the other. If it isn't the colour you tested for then it's already the other colour so change it back. CYA, Dave

« previous php.general (#115250) next »