Jump to content

Archived

This topic is now archived and is closed to further replies.

softz

Latest Addition

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.