View Single Post
Old 03-22-2005, 03:20 AM   #1 (permalink)
harryhood
The Visitor
 
Join Date: Mar 2005
Posts: 3
Thanks: 0
harryhood is on a distinguished road
Default Using a simple counter

I have a small project where records are queried from a database using php and the results are then displayed to the user. To display the results I am using a simple

PHP Code:
do {
echo 
'<tr><td style=background-color: somecolor>some text</td></tr>';

} while {......} 
routine.

What I would like to do is alternate the color of the background text in each row shown by the do - while loop. I know I can assign "somecolor" to a variable and alternate the value of somecolor based on a counter being odd or even. I just do not know how to declare or increment the counter.

I am wondering what the simplest way to accomplish this would be. Sorry if I did not explain this very well. I've been staring at a screen all day and think I am going blind. :)

Any help would be appreciated.
harryhood is offline  
Reply With Quote