trying to insert multiple input and get the last id of other table and insert in into this table for foreign key.
tried to remove from the loop and tried to use foor loop
if($result){
$j = 0;
foreach($_POST as $val){
$po_trans_id = "SELECT LAST_INSERT_ID()[$j]";
$po_qty = $_POST['po_qty'][$j];
$po_unit = $_POST['po_unit'][$j];
$po_description = $_POST['po_description'][$j];
$po_unit_price = $_POST['po_unit_price'][$j];
$po_total_amount = $_POST['po_total_amount'][$j];
$payment_terms = $_POST['paymentTerms'][$j];
$user = $_SESSION["username"][$j];
$query = "INSERT INTO request_po (po_trans_id,po_qty,po_unit,po_description,po_unit_price,po_total_amount,totalPrice,user) VALUES ('$po_trans_id' , '$po_qty' , '$po_unit' , '$po_description' , '$po_unit_price' , '$po_total_amount' , '$totalPrice' , '$user')";
$j++;
$result = mysqli_multi_query($link, $query) or die(mysqli_error($link));
}
id like to insert my last id to other table for relational database.