I want to follow the suggestions of this posts, but I have a problem of understanding: How to store complex product/order data in MySQL?
My php code looks like this:
if(isset ($_POST['submit'])) {
$payment = $_POST['payment'];
$shipping = $_POST['shipping'];
$order_person = $_POST['order_person'];
$total = $_POST['total'];
$status = $_POST['status'];
$q = "INSERT INTO orders(payment,shipping, order_person, total, status) VALUE(:payment, :shipping, :order_person, :total, :status)";
$query = $con->prepare($q);
$results = $query->execute(array(
":payment" => $payment,
":total" => $total,
":shipping" => $shipping,
":status" => $status,
":order_person" => $order_person
));
}
In my mysql database I have a row named "orders" where I have the fields:
- orderID
- date
- order_person
- shipping
- payment
- total
- status
The order ID is generated with AUTO_INCREMENT. I created a second row named "order_details". Here I want to store my product details.
My problem is: I do not understand how exactly do I store the order ID into my row "orders" and also into "order details". I would be grateful about a detailed explanation. I am so confused. Thank you very much!