cmaclennan Posted May 10, 2009 Share Posted May 10, 2009 Hi Guys, Hoping you can help me out here I have a large form that is acting as an order log there are 4 parts to the form, customer details, shipping details, order details and then the parts section I need to insert all the data into their respective tables with the ID's linking all of them together for searching? I have the form done I'm just stuck on the inserting portion at the moment. Any help is greatly appreciated. Thanks in Advance. Quote Link to comment https://forums.phpfreaks.com/topic/157620-inserting-fields-into-multiple-tables/ Share on other sites More sharing options...
Ken2k7 Posted May 10, 2009 Share Posted May 10, 2009 You would just run 4 INSERT statements that inputs the respective fields to the respective table. Quote Link to comment https://forums.phpfreaks.com/topic/157620-inserting-fields-into-multiple-tables/#findComment-831140 Share on other sites More sharing options...
cmaclennan Posted May 10, 2009 Author Share Posted May 10, 2009 how do i insert the id's from the previous table to the next to link them? Quote Link to comment https://forums.phpfreaks.com/topic/157620-inserting-fields-into-multiple-tables/#findComment-831147 Share on other sites More sharing options...
Ken2k7 Posted May 10, 2009 Share Posted May 10, 2009 I'm not following. Can you lay out an example? Quote Link to comment https://forums.phpfreaks.com/topic/157620-inserting-fields-into-multiple-tables/#findComment-831149 Share on other sites More sharing options...
cmaclennan Posted May 10, 2009 Author Share Posted May 10, 2009 Ok Well as I understand it I need to have a customer_id field in the customer table, a shipping_id field in the shipping table and a order_id field in the order table all as primary keys, now in order for me to bring up when searching all the parts associated with an order i need the order_id to be inserted into the parts table and the customer and shipping id's to be inserted into the order table so that all the info comes up when searched for, so if on the first insert query the customer_id is generated how do i insert that into the order table? hope that all makes sense. Quote Link to comment https://forums.phpfreaks.com/topic/157620-inserting-fields-into-multiple-tables/#findComment-831151 Share on other sites More sharing options...
fenway Posted May 11, 2009 Share Posted May 11, 2009 I think you're asking about LAST_INSERT_ID(). Quote Link to comment https://forums.phpfreaks.com/topic/157620-inserting-fields-into-multiple-tables/#findComment-831561 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.