i want to insert session cart into database mysql
here is my code
foreach($_SESSION['cart'] as $productid => $qty){
$query3 = "INSERT INTO dtransaction(trans_id, pro_id, quantity) VALUES ('$new', '$productid', '$qty')";
$query4 = mysqli_query($con, $query3);
print_r($query3."<br>");
}
the result of print_r
INSERT INTO dtransaction(trans_id, pro_id, quantity) VALUES ('TR033', '21', '1')
INSERT INTO dtransaction(trans_id, pro_id, quantity) VALUES ('TR033', '16', '2')
INSERT INTO dtransaction(trans_id, pro_id, quantity) VALUES ('TR033', '13', '8')
INSERT INTO dtransaction(trans_id, pro_id, quantity) VALUES ('TR033', '12', '3')
im using auto_increament (int) for detail_id but in database, inserted like this
detail_id trans_id pro_id quantity
197 TR034 21 1
201 TR035 21 1
detail_id jump 4, pro_id and quantity only insert the first data
what i want is like this
detail_id trans_id pro_id quantity
198 TR034 21 1
199 TR034 16 2
200 TR034 13 8
201 TR034 12 3
how to do that? sorry for my bad english