Or, you could do two steps

 1) retrieve the last inserted ID, with mysql_last_inserted_ID  (or
something like that).

 2) then, all records with id(s) greater then the_last_id_number minus
    five.

 something like

 $most_recent = select mysql_last_id();

 select * from TABLE where id > '$most_recent - 5';

 ...or something to that effect. There's probably a more efficient way to
 do it, but this guarantees the most recent five.


__________John Monfort_________________
_+-----------------------------------+_
     P E P I E  D E S I G N S
       www.pepiedesigns.com
"The world is waiting, are you ready?"
-+___________________________________+-

On Sat, 4 Aug 2001, Jeff Lewis wrote:

> It will give you the 5 HIGHEST values in your auto incremented field.  If it
> was returneding the first 5, or the wrong 5, repace the DESC with ASC.
>
> Jeff
>
> > -----Original Message-----
> > From: Justin French [mailto:[EMAIL PROTECTED]]
> > Sent: Saturday, August 04, 2001 6:09 AM
> > To: [EMAIL PROTECTED]
> > Cc: php
> > Subject: Re: [PHP] most recent 5 rows
> >
> >
> > Jeff Lewis wrote:
> >
> > > Try this SQL Justin:
> > >
> > > $sql = "SELECT * FROM news DESC LIMIT 5";
> >
> >
> > Hrm,
> >
> > Won't that retrieve the FIRST 5 rows, not the LAST 5?
> >
> >
> > Justin 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]

Reply via email to