How to set alternate row color for an iterated table in php?

Posted by chandru_cp on Stack Overflow See other posts from Stack Overflow or by chandru_cp
Published on 2010-04-03T10:21:24Z Indexed on 2010/04/03 10:23 UTC
Read the original article Hit count: 208

Filed under:
|
|
|

I am using php and i am iterating a table with a result array ... I want to add row color and alternate row color to it.... How to do so? Any suggestion...

<table  id="chkbox" cellpadding="0" cellspacing="2" 
               width="100%" class="table_Style_Border">
<tr>
<td style="width:150px" class="grid_header" align="center">RackName</td>    
   <td style="width:150px" class="grid_header" align="center">LibraryName</td>  
<td style="width:200px" class="grid_header" align="center">LibrarianName</td>
<td style="width:200px" class="grid_header" align="center">Location</td>
        <td style="width:1%" class="grid_header"></td>


    </tr>

     <? if(isset($comment))
           { echo '<tr>
      <td class=table_label colspan=5>'.$comment.'</td></tr>'; } ?>
    <?php foreach($rackData as $row) { ?>
    <tr>
        <td align="left" class="table_label">
                <?=$row['rack_name']?>
        </td>
        <td align="left" class="table_label">
                <?=$row['library_name']?>
        </td>
        <td align="center" class="table_label">
                <?=$row['librarian']?>
        </td>
        <td align="center" class="table_label">
                <?=$row['location']?>
        </td>
        <td align="center">
            <input type="checkbox" name="group" id="group" 
  value="<?=$row['rack_id']?>" onclick="display(this);"  > 
        </td>

    </tr>

  <?    } ?>
    <table>

© Stack Overflow or respective owner

Related posts about php

Related posts about table