I.e amount to pay more than one client for same type of products is $20,000. Client One $12,000, Client Two $3,000, Client Two $5,000. Which to total is $20,000.
I want when buyer clicks to purchase for a product and they are available,
- Select and update table until buyer amount to pay gets to zero then stop.
- Count number of rows of those he should pay and update his row.
I have tried
$qry=mysqli_query($link,"Select sum(selleramount) from sellertable Where buyer product>0");
$asum=$row[0];
($row=mysqli_fetch_array($ry));
foreach ($qry as $row) {
$balance=$buyeramount-$asum;
mysqli_query($link,"insert into buyertable (amount,seller_id,) values ('$amount_to_payseller','$sellertopayid')");
mysqli_query($link,"update sellertable set seller amount='$balance'");
}
I have tried but its not working out. I have the idea but how to go about what I want I don't know.