softz Posted June 8, 2006 Share Posted June 8, 2006 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 Quote Link to comment Share on other sites More sharing options...
akitchin Posted June 9, 2006 Share Posted June 9, 2006 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 [color=green]FROM[/color] [color=orange]table[/color] [color=green]ORDER BY[/color] id [color=green]DESC[/color] 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.