Get Id of last record inserted into a MySQL databaseIf you are inserting records into a MySQL database, e.g. a number of consumer products, and are using a ProductId field which you set to auto increment to automatically assign a ProductId, you will often need to know what Id was assigned to the last record you added. MySQL has a function to do this, it's: mysql_insert_id() So, if you have for example performed the following MySQL insert statement: //insert into database If you left the database connection open and then used the following line in your script: echo mysql_insert_id() ; This would display the Id (i.e. ProductId) of the last product you added.
|
|
All Content ©2020 WebRef.eu |