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 (
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
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
[code]
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…
[code]<?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);
?>
-
<?php do { ?>
-
<?php echo $list_latestnews['title']; ?>
<?php echo substr($list_latestnews['body'],0,80)."...";?> view more<?php echo $list_latestnews['author']; ?> - <?php echo date("l, jS F Y", strtotime($list_latestnews['date'])); ?>
<?php } while ($list_latestnews = mysql_fetch_assoc ($latestnews_query)) ?>