List Rows - Alternating Background Colours

4 posts by 3 authors in: Forums > CMS Builder
Last Post: April 7, 2008   (RSS)

Re: [Perchpole] List Rows - Alternating Background Colours

By Dave - April 2, 2008

Here's a little shorthand PHP I often use:

<?php $bgColor = (@$bgColor == "#CCCCCC") ? '#EEEEEE' : '#CCCCCC'; ?>

Just replace the '#CCCCCC' and '#EEEEEE' with the colors you want and put that just below the start of your foreach loop. Then you can print out the bgColor value like this:

bgcolor="<?php echo $bgColor; ?>"

You could also use that to rotate a classname if you want to use CSS for your background color.

Hope that helps! :)
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] List Rows - Alternating Background Colours

By Perchpole - April 3, 2008

Brilliant.

Now you're just showing-off!

[;)]

AJ

Re: [Perchpole] List Rows - Alternating Background Colours

By DHester - April 7, 2008 - edited: April 7, 2008

I used your alternating background color code also Dave. Thanks!
Darren Hester
www.designsbydarren.com