Click to See Complete Forum and Search --> : How can I retrieve the AUTO_INCREMENT ID


Anon
11-13-2000, 04:31 AM
Hi,
In MySql, I had a table with a AUTO_INCREMENT column, when I insert a row to it, how can I retrieve this column ID value?

Thnks...

Anon
11-13-2000, 05:31 AM
You can do it by using mysql_insert_id.

lancelot_

Anon
11-13-2000, 05:10 PM
for example:

$query = mysql_query("INSERT INTO table (field) VALUES ('foo')");
$genID = mysql_insert_id();