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>

Rate this knowledge base item


  • 1
    Poor

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
    Great
 
blog comments powered by Disqus

Topics

About

Amit Arora is web developer with expertise in developing eCommerce enabled websites for the businesses.

Contact | Resume

Subscribe to newsletter




Get Firefox

Monitored by Site24x7
Uptime