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:[EMAIL PROTECTED] |
| Phone : (613) 731-4046 x.109                 |
:----------------------------------------------:
| Website : http://www.webmotion.com           |
| Fax     : (613) 260-9545                     |
`----------------------------------------------'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to