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:
id,heading,text,user


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

---
$db = mysql_connect("localhost", "root", "");
mysql_select_db("soundpimp",$db);

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

while ($sql_myrow = mysql_fetch_array($sql_result))
        {
        echo 
$sql_myrow["id"]."<BR>".$sql_myrow["heading"]."<BR>".$sql_myrow["text"]."<BR>".$sql_myrow["user"]."<BR>---<BR>";
        }
---

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


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