RE: [PHP-DB] Getting last row, moving backwards..
| From: | Mark Roedel | Date: | Fri, 19 Jan 2001 15:31:37 +0000 |
| Subject: | RE: [PHP-DB] Getting last row, moving backwards.. | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-5983@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Chad Day [mailto:chad@beachassociates.com]
> Sent: Friday, January 19, 2001 9:15 AM
> To: 'php-db@lists.php.net'
> Subject: [PHP-DB] Getting last row, moving backwards..
>
>
> I need some help selecting the last row in my database, and then
> moving backwards.. I can't just get mysql_num_rows and go back by
> 1, as some of the records are missing.. the ID field might have #'s
> like 1950, 1948, 1947, 1944, etc, and I don't want it to break by
> mistakingly trying to grab 1949. Can someone provide some help or
> a link to where in the manual what I'm doing might be explained?
> Been searching, no luck yet. Thanks!
Wouldn't it be easier to just get them from the database in the order that
you want?
In your example, something like
select * from mytable order by id_field desc
would likely do the trick (sorting your results by the value of the ID
field, in descending order).
---
Mark Roedel | "A wise man once told me that everything in
Systems Programmer | life is either a lesson or a joke. Our task
LeTourneau University | is to figure out which is which..."
Longview, Texas, USA | -- Chris Savage