Hi Guys, I am inserting values in two tables. After the insert of values in the first table, I want to get the inserted ID(first table) because I need that value in my second table.This is my code but I think it will gives error when there are many values inserted I am right? Or I should use mysql_insert_id()? Is it ok using mysql_insert_id()? Thank you

SELECT max(sampid) as sampid FROM sampinfo

you should have generated an id for both tables before you insert the data.
because i think querying for max id is not the answer when you have more than 1 user using whatever it is you building.

Member Avatar

diafol

mysql_insert_id used to be the way to do it. Now it.s the pdo or mysqli equivalent.