Re: mysql quickie..
| From: | Robert Cummings | Date: | Wed, 17 Apr 2002 18:23:48 +0000 |
| Subject: | Re: mysql quickie.. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-93365@lists.php.net to get a copy of this message | ||
Kelly Meeks wrote:
>
> Hi folks,
>
> I need to get the next auto_increment value of a mysql table thru php.
>
> Looking at my mysql manual, it makes reference to a last_insert_id() function?
>
> How would I use this via php, or is there some other way to do it?
Quickly and hardly accurately... but good enough for useful purposes:
mysql_query( 'SELECT last_insert_id()' );
if( ($row = mysql_fetch_assoc()) )
{
$id = $row['last_insert_id()'];
}
Cheers,
Rob.
--
.-----------------.
| Robert Cummings |
:-----------------`----------------------------.
| Webdeployer - Chief PHP and Java Programmer |
:----------------------------------------------:
| Mail : mailto:robert.cummings@webmotion.com |
| Phone : (613) 731-4046 x.109 |
:----------------------------------------------:
| Website : http://www.webmotion.com |
| Fax : (613) 260-9545 |
`----------------------------------------------'