Getting the last few rows?

They have: 850 posts

Joined: Jul 1999

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

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

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

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.