Code: Select all
<?php
$result = mysql_query($query) or die ("Query failed");
$numofrows = mysql_num_rows($result);
if(isset($_GET['search']))
{
if(isset($list) && count($list) > 0)
{
foreach($list as $row)
{
$i = 0; $i < $numofrows; $i++;
print "<tr class=\"car-row-".($i % 2)."\">";
?>
<td><a href="index.php?option=com_jumi&fileid=5&Itemid=44&vehicle_id=<?php echo $row['listingid']; ?>"><img src="http://www.findabreaker.co.uk/breakeradmin/uploaded/<?php echo $row['car_image']; ?>" /></a></td>
<td><?php echo $row['listing_title']; ?></td>
<!--<td width="20%"><?php //echo $row['cat_name']; ?></td>--?
<!--<td width="20%"><?php //echo $row['postcode']; ?></td>-->
<?php
if(isset($_GET['postcode']) && strlen($_GET['postcode']) > 0)
{
?>
<td><?php echo $row['distance']; ?> kms</td>
<?php
}
?>
<td><?php echo $row['county_name']; ?></td>
<td><img src="images/glass.gif" width="16" height="16" border="0"/><a href="index.php?option=com_jumi&fileid=5&Itemid=44&vehicle_id=<?php echo $row['listingid']; ?>"> View Details</a></td>
</tr>
<?php
}
}
else
{
echo 'No vehicles found!';
}
}
?>
</tbody>
</table>
</div>
What I'm trying to do is have alternating colours for the rows, but after looking everywhere on the net, none of the solutions work, I need to have a different style for alternating rows, like <tr class="class-1"> next row <tr class="class-2"> next <tr class="class-1"> etc... I hope you understand what I mean and anyone who can help me out I'd really really appreciate it.