Three alternating css class using PHP

Posted July 29th, 2008 in CSS, Programming by Louie Miranda

My code for three alternating class:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<div class=row_0>content here</div>
<div class=row_1>content here</div>
<div class=row_3>content here</div>
 
    <?php
    $i=0;
    foreach ($row as $data)
    {
    $i+1;
    $row_class = ($i % 3);
    //tpl class
    echo 'class=row_'.$row_class;
    }
    ?>

HTH