How to get AUTO_INCREMENT ID of the last MySQL Insert with PHP

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.

Related posts:

Share

About number.0