Odd and Even row

To find odd or even row for different purpose. For one example: Here we used this concept for two different types of colors filled in TR tag of html.

 
Example Code:

//for displaying status in table $sqlquery="SELECT backup_date, backup_status FROM backup_history where backup_date > '$fromDate' and backup_date<='$toDate' and mach_oid='$machine_oid' order by backup_date desc"; $sqlresult=mysql_query($sqlquery,$Link); $sqlnum=mysql_num_rows($sqlresult); $sqlrowno=1; $loopvar=0; ?> <table> <?php while ($row = mysql_fetch_array($sqlresult,MYSQL_ASSOC)) { $backupdate = $row['backup_date']; $backupdate = date(" d M y ",strtotime($backupdate)); $backupstatus=$row['backup_status']; $status=getStatus($backupstatus); //For find odd or even row. if ($loopvar%2 ==0) { $rowclass="even"; // here “even” variable is an object in style sheet. We used the color values in style sheet for both “even” and “odd”. } else { $rowclass="odd"; } ?> <tr class='<?php echo $rowclass; ?>'> <td><?php echo $backupdate;?></td> <?php } $loopvar++; ?> </tr> <?php } ?> </table>