PHP Quicky - Alternate table row colors
Time for another simple PHP hack. This time, instead of explaining a function and how to use, I will give you a simple, one liner for alternating colors in table rows.
You see this often in tables with lots of data, rows alternate color (white/grey for example). Designers do this to make it easy for the eye to follow a row. It's a quick visual guide for accuracy.
so without further ado, here's the code:
<tr bgcolor="<?php echo ($clrCounter++ % 2 == 0 ? 'color1' : 'color2'); ?>"> color 1, color 2 should be HEX codes (ie. #ffffff, #ff0000)
Enjoy!
WebPro
-
jminkler -
Thanks
{{ DiscussionBoard.errors[3345125].message }} -