slaterino Posted July 8, 2009 Share Posted July 8, 2009 Hi, I have 2 tables which need to be updated from the same form. I created 2 Insert Into queries to insert the data from the form into the tables, but have one massive problem. As the 2 tables need to be linked, I need the auto ID from the first table to be present in the second table. This id would not be created until after the queries have been run, so how would I go about getting this inserted into the second table? Does anyone have any suggestions? Thanks Russ Quote Link to comment https://forums.phpfreaks.com/topic/165214-having-problems-inserting-data-into-2-linked-tables-from-same-form/ Share on other sites More sharing options...
rhodesa Posted July 8, 2009 Share Posted July 8, 2009 After your first INSERT, use mysql_insert_id() to get the auto_increment id. Then use that in the second INSERT Quote Link to comment https://forums.phpfreaks.com/topic/165214-having-problems-inserting-data-into-2-linked-tables-from-same-form/#findComment-871213 Share on other sites More sharing options...
slaterino Posted July 8, 2009 Author Share Posted July 8, 2009 Thanks! I'll give it a try in a minute. Quote Link to comment https://forums.phpfreaks.com/topic/165214-having-problems-inserting-data-into-2-linked-tables-from-same-form/#findComment-871222 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.