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 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 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. 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
Archived
This topic is now archived and is closed to further replies.