• 0

Need to add child row in mySql through php


Question

Okay so it;s a bit weird but I was hoping maybe you guys. So, it goes something like this: I've a mySQL table with 4 columns i.e address, phone, email and name. Now I created another table where I would store their order names and prices. But how do I link the two? I mean I can create a front end where I can add customer to the customer table but when I try to add the order through the frontend I don't know how to link the order with the correct customers in the customer table? I know how to link the orders with their respective customer in the database but how do I achieve the same through frontend?

1 answer to this question

Recommended Posts

  • 0

If i understand what your trying to do, you need a CustomerId field on both tables (with a foreign key constraint).

insert into customers_tbl (...)

                    values (...)

                    where CustomerId = :CustomerId

This topic is now closed to further replies.