PHP mysqli_insert_id() Function

PHP mysqli_insert_id() function returns the auto-generated id used in the last query.

Syntax

mysqli_insert_id() Function Parameter

ParameterDescription
Connection :Required parameter. The MySQL connection to be used

mysqli_insert_id() Function Return Value

Return Values :Returns the value of the AUTO_INCREMENT field that was updated by the previous query.

mysqli_insert_id() Function Example