Hello.
If I want to display a most recent row from a database table, how would I do that? All rows would have a MySQL timestamp and an ID. There is a array_pop function, but it is not very accurate and only gives the last row. If I need five last rows, how would I do that?
Thanks.
Siaplaying most recent rows
Moderator: General Moderators
- evilmonkey
- Forum Regular
- Posts: 823
- Joined: Sun Oct 06, 2002 1:24 pm
- Location: Toronto, Canada
-
pootergeist
- Forum Contributor
- Posts: 273
- Joined: Thu Feb 27, 2003 7:22 am
- Location: UK
Code: Select all
ORDER BY id DESC LIMIT 5Code: Select all
ORDER BY id DESC LIMIT 0,5- evilmonkey
- Forum Regular
- Posts: 823
- Joined: Sun Oct 06, 2002 1:24 pm
- Location: Toronto, Canada
What's the difference?Kriek wrote:Although I do this ..Code: Select all
ORDER BY id DESC LIMIT 5
Code: Select all
ORDER BY id DESC LIMIT 0,5
Thanks I got it going.
If you only use one parameter, it will be the number of rows to return, if you use two parameters, it will be where to start, and then the number to return. Start at row * and pull * results.evilmonkey wrote:What's the difference?
Code: Select all
ORDER BY id DESC LIMIT 0,5