September 12, 2008

Alternating Table Backgrounds in PHP

If you like the alternating table backgrounds that are in applications like iTunes, and want them in your web application, there is a simple way to do so in PHP:

<table>
 <tr class="title">
  <td></td>
 </tr>
<?php
$i
=0;
foreach(
$row as $r){
   if(
$i&0){$alt=' class="even"';}else{$alt='';}
   echo 
"<tr".$alt.">";
   
//other table stuff in here
   
$i++;
   echo 
"</tr>";
}
?>
</table>

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

You must be logged in to post a comment.