I have two tables
transaction_tbl
order_tbl
I inserted data in transaction_tbl
with a primary key autoincrement transaction_no
.
Now, I need to insert data in order_tbl
with columns
orderitem_no(AI, PK),
transaction_no,
product_sku,
quantity
How can I sync the transaction_no
from transaction
table in one process?
I just assign data to variables then:
My current code is
$sql0 = "INSERT INTO transaction_tbl (transaction_no, transaction_date, customer_name) VALUE ('', now(), '$customer_name');";
$x=0;
while ($x!=5){
$sql1 = "INSERT INTO order_tbl
(orderitem_no, transaction_no, product_sku, quantity)
VALUE ('', '', '$product_sku', '$quantity');";
$x=$x+1;
}
Nothing next. Sorry, Im super lost.
Im planning to run ths sql's in one process.
transaction_no in transaction_tbl is auto increment.
I have fk_trans_no in order_tbl.
And then I totally lost. orderitem_no is auto increment but what will I do to the transaction_no?