PHP/MySQL Get autoincremented value after insert
Use LAST_INSERT_ID() in SQL
SELECT LAST_INSERT_ID();
Use mysql_insert_id() in PHP
There's a PHP and also a MySQL function for this: mysqli_insert_id()
and PDO::lastInsertId()
.
http://php.net/manual/en/function.mysql-insert-id.php