I am trying to get the Total Sum of values from a table. Query works without WHERE Clause, but i need to get the total sum per user. Like user ABC has 100USD and user BDC has 200USD. Here is the code
$PWithdrawls = mysqli_query($con, "SELECT * FROM withdraw WHERE status='Pending'"); $S_NO = 0; while ($row = mysqli_fetch_assoc($PWithdrawls)) { $S_NO++; $posted_by = mysqli_query($con,"SELECT * FROM users WHERE userId=".$row['seller_id']); $user_ad = mysqli_fetch_assoc($posted_by); $TotalOrders_Amount = mysqli_query($con, "SELECT SUM(amount) as total FROM orders WHERE userId=".$row['seller_id']); $sum_amount = mysqli_fetch_assoc($TotalOrders_Amount); $sum = $sum_amount['total'];
And here is my call
<td>$<?php echo $sum; ?></td>
https://stackoverflow.com/questions/65400957/unable-to-get-the-value-from-a-query-with-where-clause December 22, 2020 at 06:43AM
没有评论:
发表评论