Hi all,

I have a table with the column "id", which is a unique number, 
auto-incremented, so the highest "id" is the most recent.

I wish to retrieve the last five rows from the table (there 
will be hundreds of rows) and print some columns to the screen.

I have this table:

This is what I have, which retrieves ALL rows, in id order, from
smallest to greatest:

$db = mysql_connect("localhost", "root", "");

$sql = "SELECT * FROM news";
$sql_result = mysql_query($sql);

while ($sql_myrow = mysql_fetch_array($sql_result))

What I'd like to do is ONLY echo the highest 5 id's (the latest 5 rows),

How do I approch this?  Do I find the highest ID, then do 5 SELECTS,
counting back?

Any code / ideas appreciated.

Jsutin French

PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to