Sorry, forgot the ORDER BY, here is what you're looking for:
$sql = "SELECT * FROM news ORDER BY id DESC LIMIT 5";
In a list of numbers up to 10, this would return rows 6,7,8,9, and 10.
Jeff
www.hyrum.net
www.xnull.com
> -----Original Message-----
> From: Jeff Lewis [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, August 04, 2001 7:06 AM
> To: [EMAIL PROTECTED]
> Cc: php
> Subject: RE: [PHP] most recent 5 rows
>
>
> 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]