I have a problem with alternating the rows of my php dynamic table. I saw an example here which I was able to use but I dont understand how to switch between between html and the php on the <tr class= <?php "' . $class .'" ?>' altrow is my css class definition. below is my mark up:
Can someone please show how to achieve this alternation? Thanks
Code:
<tr>
<th scope="col">Trackid</th>
<th scope="col">NMEA</th>
<th scope="col">Date</th>
</tr>
$result = mysql_query($sql, $link);
$i = 0;
if (!$result) {
die("Query to show averages from table failed");
}
while ($row = mysql_fetch_assoc($result)){
$class = ($i++ % 2) ? 'altrow' : '';
?>
<tr class= <?php "' . $class .'" ?>>';
<td><?php echo $row['Trackid']; ?></td>
<td><?php echo $row['NMEA']; ?></td>
<td><?php echo $row['Date']; ?></td>
</tr>
<?php } ?>
</table>
Comment