This is my question/problem.
I have a table with orders and a table with order details.
Clients can order multiple products at once during one order, so one line has to be inserted in the main order table, and multiple order details from the same order in the order detail table.
How do I do this?
Right now if a client orders 5 products during one order, the order detail table looks fine, but also get 5 records in my main order table. It has to be one.
I probably have to change my SQL statement for this, but don't really know how.
Any suggestions?
(renatef_bestellingen is the main ordertable, renatef_besteldetail is the order detail table)
A part of my current code:
Expand|Select|Wrap|Line Numbers
- $sql = "INSERT INTO renatef_bestellingen (KLANT_ID, besteldatum, besteluur, leveringswijze, leveringskost) VALUES ('$klantid', '$datum', '$uur','$leveringswijze', '$leveringskost')";
- $theresult = mysql_query($sql);
- $bestelid = mysql_insert_id();
- $sql2 = "INSERT INTO renatef_besteldetail (bestelling_id,product_id,aantal)VALUES (".$bestelid.",'$key','$val')";
- $theresult2 = mysql_query($sql2);
the 'renatef_bestellingen' picture shows that 2 records are made with the same info, it should only be 'BESTELLING_ID' with value 26
in the 'renatef_besteldetail' picture everything is correct except for the 'bestelling_id' which both should be value 26
I also added a print screen of more of my code.
thanks in advance for your help! I keep looking myself but it is really urgent so any help is very welcome.