Jump to content


Photo

Latest Addition


  • Please log in to reply
1 reply to this topic

#1 softz

softz
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 08 June 2006 - 11:47 PM

hey guys, ive got my database and eveything set, and i can see all the news thats in there, but i need to be able to make a page that displays only the last entry into the database and then one that will disply only the last 5 entrys from one feild

how do you do it so only the last entry into the database is shown?

cheers in advance

#2 akitchin

akitchin
  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 09 June 2006 - 02:00 AM

assuming you have some sort of information to note which the most recent entry is (ie. an auto_increment ID, date/time it was entered, etc), just order the entries by the value and limit the query. for example, if i had a column named 'id' which was an auto_increment column, i would go:

[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] stuff FROM table ORDER BY id DESC LIMIT 5 [!--sql2--][/div][!--sql3--]

for the 5 most recent entries. merely a matter of sorting and limiting - what you do with the sorting depends on your column type.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users