KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a mysql question. I have a news section on my website, and I want to display the two latest items. If I do: SELECT * FROM nieuws ORDER BY id DESC LIMIT 1 it selects the latest item, and now I want to select the second to last item. Do you guys know how to do it? /// EDIT Now it doesn't work, here's my code: (I have connect included ;) ) $select = mysql_query("SELECT * FROM nieuws ORDER BY id DESC LIMIT 1"); while($row = mysql_fetch_assoc($select)) { $datum = $row['time']; $titel = $row['title']; $bericht = $row['message']; ?> <div class="entry"> <span class="blue date"><?php echo "$datum"; ?></span> <h3><?php echo "$titel"; ?></h3> <p><?php echo "$bericht"; ?></p> <br /> </div><!-- end of entry --> <?php } ?> <?php $select2 = mysql_query("SELECT * FROM nieuws ORDER BY id DESC LIMI 1, 1"); while($row2 = mysql_fetch_assoc($select2)) { $datum = $row2['time']; $titel = $row2['title']; $bericht = $row2['message']; ?> <div class="entry"> <span class="green date"><?php echo "$datum"; ?> </span> <h3><?php echo "$titel"; ?></h3> <p><?php echo "$bericht"; ?></p> </div> <!-- end of entry --> <?php } ?> </div><!-- end of news -->
Tags (comma-separated)
Save Edits
Cancel