Try this SQL Justin:
$sql = "SELECT * FROM news DESC LIMIT 5";
Jeff
> -----Original Message-----
> From: Justin French [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, August 04, 2001 5:52 AM
> To: php
> Subject: [PHP] most recent 5 rows
>
>
> 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["t
> ext"]."<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]
>
>
>
--
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]