Basic Database Loop to display records

<?
//You can use the following script to take data from database and list, for each round it will print the tr and also each round column color will be change with the class2 and class 3.
//I am sorry I can now write more about this, this is I am just posting for my reference, if you like you can use this. If you want to know more about this please post a comment, I will try my best to help you (If I am free).
?>
<table border="0" width="100%" cellpadding="5" style="border-collapse: collapse">
<tr>
<td class="class1" align="left" valign="top"><b>Staff Number</b></td>
<td class="class1" align="left" valign="top"><b>First Name</b></td>
<td class="class1" align="left" valign="top"><b>Last Name</b></td>
<td class="class1" align="left" valign="top"><b>Email Address</b></td>
<td class="class1" align="left" valign="top"><b>Date Of Birth</b></td>
</tr>
<?
$sql
= "SELECT * FROM tablename ORDER BY fldFirstName ASC";
$result = mysql_query($sql, $db);
$rows = mysql_num_rows($result);
if(
mysql_num_rows($result)) {
$howmany = 0;
for (
$i = 0; $i < $rows; $i++) {
$data = mysql_fetch_object($result);
$howmany = $howmany + 1;
$MYXXX = $howmany % 2;
switch (
$MYXXX) {
case
1:
$MYbgcolor = "class=\"class2\"";
break;

case
0:
$MYbgcolor = "class=\"class3\"";
break;
}
?>
<tr <?=$MYbgcolor?>>
<td align="left" valign="top"><?=$data->EmployeeNo?></td>
<td align="left" valign="top"><?=$data->FirstName?></td>
<td align="left" valign="top"><?=$data->LastName?></td>
<td align="left" valign="top"><?=$data->Email?></td>
<td align="left" valign="top"><?=$data->DateOfBirth?></td>
</tr>
<?
}
}
?>
</table>