|
Get the last inserted id in from php on a mysql database |
|
|
|
|
This is useful when you are working with multi page forms. If you want to update some information on one page, for one record, and then move to another page and update the same record some more you will need the primary key id field, This is applicable to the case where the id field is an auto increment, which is the case seen in most circumstances. The code is really simple, lets take a look at how its done.
This snippet inserts a value into a test table. The statement that gets the lastid is the mysql function last_insert_id(). We gave this an alias by saying as lastId The result is looped as an associative array, and wallah, we have the id of the last insert.
|
|
Last Updated ( Thursday, 18 September 2008 )
|