Hey guys, bascially I'm developing a simple news script, and part of it has a "quick news" section, which will display the latest 3 (or any number I want) news items, each seperated by a line (<hr> in the example below).
What I want to acheive is the top 2 news items have a set LI class assigned to them, and then the 3rd LI in the list to have a different style attached to it (one without a bottom border basically), so it'll bascially repeate out the normal <li> until it hits the last item to be output, at which point it uses a LI with a class attached to it.
What I don't know how to do, is tell the PHP that once it's out putted 2 LI's, then the 3rd LI is to have a different class on it.
eg
<li>News Item 1</li>
<li>News Item 2</li>
<li class="last">News Item 3</li>
I'm pretty new to PHP so not sure how to achieve this and would appreicate any help you can offer.
Here's my code so far...
<?php
$latestnews_sql = "SELECT * FROM news ORDER BY date DESC LIMIT 3";
$latestnews_query = mysql_query($latestnews_sql) or die (mysql_error());
$list_latestnews = mysql_fetch_assoc ($latestnews_query);
?>
<ul>
<?php do { ?>
<li><p><strong><?php echo $list_latestnews['title']; ?></strong></p>
<?php echo substr($list_latestnews['body'],0,80)."...";?> <a href="news-detail.php?ID=<?php echo $list_latestnews['ID']; ?>">view more</a></p>
<p><span style="font-size:13px; font-style:italic;"><?php echo $list_latestnews['author']; ?> - <?php echo date("l, jS F Y", strtotime($list_latestnews['date'])); ?></span></p>
<hr />
</li>
<?php } while ($list_latestnews = mysql_fetch_assoc ($latestnews_query)) ?>
</ul>