How do I create alternating color table rows using php ?
27 May 2004, 05:56 pm IST
User Rating: 4.8 (84 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>
Topics
- Apache (2)
- Javascript (1)
- PHP (5)
- Windows (3)
About
Amit Arora is web developer with expertise in developing eCommerce enabled websites for the businesses.
Monitored by Site24x7
Uptime