The mysqli_insert_id() function returns the ID generated by the AUTO_INCREMENT
mechanism in the last query.
Practical use: When you insert a new record into a table, this function immediately returns the unique number (ID) that the database assigned to this record. Look at the example below: