I am wondering if it is possible to alternate between even and odd in my news system which is in a while loop. I currently have:
If you didn't notice, the "li" has even as the class. I am wondering if when the while loop goes around for the second time to make the even change to odd? So it would display:
It would display this in the source code. Many thanks for your help!
| Code: |
|
$getfrom = mysql_query("SELECT * FROM `news` ORDER BY `id` DESC LIMIT 0, 3"); while($news = mysql_fetch_array($getfrom)) { $title = $news['title']; $short = $news['shortmsg']; $id = $news['id']; $date = $news['datep']; echo "<ul class='widelist'> <li class='even'> <a href='news.php?id=$id'>$title</a><div class='newsitem-date'>$date</div> </li> </ul>"; } |
If you didn't notice, the "li" has even as the class. I am wondering if when the while loop goes around for the second time to make the even change to odd? So it would display:
| Code: |
| <ul class='widelist'>
<li class='even'> <a href='news.php?id=$id'>$title</a><div class='newsitem-date'>$date</div> </li> </ul> <ul class='widelist'> <li class='odd'> <a href='news.php?id=$id'>$title</a><div class='newsitem-date'>$date</div> </li> </ul> |
It would display this in the source code. Many thanks for your help!
