Getting the last few rows?
Hi,
I am creating a little news script to get a little experience with PHP + Mysql. I have done the backend stuff, but now I need to display X number of news bits.
Since the latest news is appended to the database, I will need to somehow grab X amount of rows from the bottom of the table. Could someone possibly give my the correct SQL syntax for this?
Thanks.
------------------
http://www.wiredstart.com : The Technology Start Page
http://www.thehungersite.com - http://www.therainforestsite.com
http://www.ratemymullet.com - Beauty is only mullet deep.
Rob Pengelly posted this at 04:54 — 9th April 2000.
They have: 850 posts
Joined: Jul 1999
Thanks. Just had to add a while($ticker <= 15) and it worked great.
------------------
http://www.wiredstart.com : The Technology Start Page
Patrick Davis posted this at 05:16 — 9th April 2000.
They have: 30 posts
Joined: Apr 2000
I would just sort the entries in desendint order and pull out the first five.
Sort by date:
$query="SELECT * FROM news ORDER BY Date DESC";
$mysql_result=mysql_query($query);
while($row=mysql_fetch_row($mysql_result)){
//Do whatever needs to be done
}
Why am I not a moderator on this board
------------------
Good looking by Nature... Intelligent by Practice
http://dlo.net/process/profile.php3?user=Westwood
OMG It's Furious George!!!
roBofh posted this at 14:12 — 9th April 2000.
They have: 122 posts
Joined: Jun 2000
of course, there's always 'LIMIT'
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.