How do I create alternating color table rows using php ?
27 May 2004, 08:26 am IST
User Rating: 4.3 (33 votes)
Taking an example of listing a bunch of name in differnt rows ...
<table border='0' cellpadding='5' cellspacing='0'> <?php $bgc = TRUE; //Initialize the variable foreach(array('city', 'address', 'city', 'state', 'zip', 'country') as $e) { echo '<tr', ($bgc = ! $bgc ? " bgcolor='#eeeeee'" : '' ), "><td>$e</td></tr>"; } ?> </table>


