Alternating Row Color

April 25, 2003 by  
Filed under Tips and Tutorials

alternate colors Interested in alternating row colors in your tables? But how would you do that easily in PHP?

No matter where you data is, whether it’s in an array, database, or file, this can be done simply.

The code:
<tr bgcolor=”<?=($i%2)?”#ffffff”:”#c0c0c0″;?>”>
<td>YOUR DATA GOES HERE</td>
</tr>

is the answer. I’ve written a small tutorial on it here.

Related Posts Plugin for WordPress, Blogger...

Comments are closed.