$subtotal = $pdo->query(
"SELECT
s.quan as quan,
s.price as price,
p.store_id as store_id
FROM `stock` as s
JOIN product as p ON s.prod_id = p.prod_id "
);
while ($row_ = mysqli_fetch_array($subtotal)){
$subtotal_price += $row_["quan"]*$row_["price"];
$pdo->query(
"INSERT INTO `order_record` (
`subtotal_price`
)
VALUES
(
"{$subtotal_price}"
) "
);
}
stock will have merchandise ID and quan, price, merchandise ID will not repeat.
I have a problem now!
store_id is a store ID
product noodles each item has a store_id value (will be repeated)
I want to add data to order_record
, but only if
assumes that the store_id of the product is the same
when querying (or during while tracking), then multiply quan and price into $subtotal_price, on the iteration side, and then add the number to the order_record profile
, that is, fake the store_id of the product. Just once.
how can I write this?