I have a shopping cart form that once I submit the form I loop the POST values to print it on a table.Here is the loop for the items sold
<?php
for($i = 0; $i < count($_POST["id"]); $i++){
echo "<tr>";
echo "<td>".$_POST["name"][$i]."</td>";
echo "<td>$ ".$_POST["price"][$i]."</td>";
echo "<td>".$_POST["quantity"][$i]."</td>";
$total[$i] = $_POST["price"][$i]*$_POST["quantity"][$i];
echo "<td>$ ".$total[$i]."</td>";
echo "</tr>";
?>
My question is based on this loop I need to compare it to a product DB that has the following fields
|Name | Price | QtyLeft | QtySold | where QtyLeft is the current quantity in stock. So based on the code above how do I query my table to subtract the quantity of the item sold to the QtyLeft and update QtySold?
For each item in the loop: