Sometimes you may need to retrieve the ID of your latest record after inserting into MySQL. If you are using AUTO_INCREMENT columns for storing IDs then this is simple:
Use mysql_insert_id() function in PHP
Return Value:
- The ID generated by the latest INSERT statement OR
- 0 if no ID was generated OR
- FALSE if MySQL connection failure.