How to format every secound row in a database result

From: Date: Wed, 30 Mar 2005 19:02:53 +0000
Subject: How to format every secound row in a database result
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-211905@lists.php.net to get a copy of this message
On Mar 30, 2005, at 12:08 PM, Richard Davey wrote:
Hello Leif, Wednesday, March 30, 2005, 6:54:15 PM, you wrote: LG> http://www.devtek.org/tutorials/alternate_row_colors.php There is no need to involve a math heavy modulus function just to alternate row colours! The following single line will do it just as well, swap the colours for whatever you need and echo them where required: $bgcolor = ($bgcolor === '#daf2ff' ? '#c9e1ef' : '#daf2ff'); Best regards, Richard Davey
It does not involve heavy math to color every other line. I use this line when looping and determining if the background should be colored or not: <?php if (($i % 2) == 0) echo ' style="background: #A8B1E9;"'; ?> Obviously, the first part is the important part. Good luck! ~Philip

« previous php.general (#211905) next »