Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.