PHP mysqli_insert_id() Function

The mysqli_insert_id() function returns the id (generated with AUTO_INCREMENT) used in the last query.

mysqli_insert_id(connection);

Example -

Assume that the Persons table has an auto-generated id field. Return the id used in the last query:

ParameterDescription
connectionRequired. Specifies the MySQL connection to use