Re: getting lines from the highest ID in a database?
| From: | Maxim Maletsky | Date: | Fri, 05 Apr 2002 11:03:59 +0000 |
| Subject: | Re: getting lines from the highest ID in a database? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-91685@lists.php.net to get a copy of this message | ||
add to your mySQL query:
" order by id desc limit 1"
This will order your data by your primary id (change 'id' to whatever you auto-increment) in the descending order and will limit the results to 1 record.
Cheers,
Maxim Maletsky
Founder, Chief Developer
PHPBeginner.com (Where PHP Begins)
www.PHPBeginner.com
maxim@phpbeginner.com
Hawk writes:
Lets say I have a guestbook, and that I only want to show the last entry on my first page I cant figure out a good way to do it.. haven't managed to find a mysql command that can do it either, but maybe there are? :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.phpMaxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) www.PHPBeginner.com maxim@phpbeginner.com