Get auto-incremented value with PHP / mySQL

When you do an insert SQL statement which creates a new record, you often want to return the value of the auto-incremented field.

You can do this in PHP by:

$recid = mysql_insert_id(); //Return the number of the automatically incremented field after the insert statement

this is done after your mysql_query($sqlquery); statement

Leave a Reply