please i am trying to echo the sumation of a column in the next row
, but it is displaying with the prev row.
this is the code
$body = "<html><body><table border='1'>
<tr>
<th>Shop Name</th>
<th>Product Name</th>
<th>Size</th>
<th>Color Name</th>
<th>Quantity</th>
<th>Price</th>
<th>Cost</th>
</tr>";
$totalPrice = 0;
$pplresult = mysql_query("SELECT * FROM repplac WHERE Uname = '{$_SESSION['username']}'");
while($row = mysql_fetch_assoc($pplresult)){
$body .= "<tr>
<td>" . $row['Sname'] ."</td>
<td>" . $row['Pname'] ."</td>
<td>" . $row['Psize'] ."</td>
<td>" . $row['Pcolour'] ."</td>
<td>" . $row['Pquantity'] ."</td>
<td>" . $row['Price'] ."</td>
<td>" . $row['Tprice'] ."</td>
</tr>";
$totalPrice += $row['Tprice'];
}
$body .= "<tr>
<td>" . $totalprice ."</td>
</tr>";
$body .="</table></body></html>";
You want to display the total under the last column right?
for that you will need to add some td’ s in the later tr i.e.,
Even your code is not appropriate. Why would you iterate through that while loop twice for the same mysql query result set,