PHP mysqli_insert_id() Function
Assume the websites table has an auto-generated ID field. Return the ID from the last query:
Definition and Usage
The mysqli_insert_id() function returns the auto-generated ID from the last query (generated by AUTO_INCREMENT).
Syntax
mysqli_insert_id(
connection
)
;
| Parameters | Description |
|---|---|
| connection | Required. Specifies the MySQL connection to use. |
Technical Details
| Return Value: | Returns an integer with the value of the AUTO_INCREMENT field that was generated in the last query. If the number is greater than the maximum integer value, it returns a string. If there was no update or no AUTO_INCREMENT field, 0 is returned. |
|---|---|
| PHP Version: | 5+ |
PHP MySQLi Reference Manual