Jump to content

Latest Addition


softz

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
Link to comment
https://forums.phpfreaks.com/topic/11541-latest-addition/
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.
Link to comment
https://forums.phpfreaks.com/topic/11541-latest-addition/#findComment-43480
Share on other sites

Archived

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

×
×
  • Create New...

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.