| | #1 |
| PeaceRoom Member Join Date: 2011 Location: Montreal, Canada
Posts: 85
Thanks: 12
Thanked 9 Times in 9 Posts
|
Good day fellow warrior programmers, 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: Code: <tr bgcolor="<?php echo ($clrCounter++ % 2 == 0 ? 'color1' : 'color2'); ?>"> color 1, color 2 should be HEX codes (ie. #ffffff, #ff0000) Enjoy! WebPro |
| |
| | #2 |
| WebNinja Join Date: 2010 Location: Atlanta GA
Posts: 444
Thanks: 19
Thanked 54 Times in 34 Posts
|
Should add $clrCounter = 0; first
|
| |
|
| Bookmarks |
| Tags |
| alternate, colors, php, quicky, row, table |
| |