Forum Moderators: coopster
while($row=mysql_fetch_array($result)) {
$Body .= $row['final_price'] =$row['products_name'] =$row['products_quantity'];
}
Products: 24
Products: ItemName 2 ItemName 4
I've managed to split it up onto seperate lines and make it far easier to read.
$total = 0;
$products = null;
while($row=mysql_fetch_array($result)) {
$price = $row['final_price'];
$pname = $row['products_name'];
$quan = $row['products_quantity'];
$subtotal = sprintf(("%.2f",$row['final_price']); // format "1234.00"
$total += $subtotal;
$products .= "
<tr>
<td align=\"center\">$pname</td>
<td align=\"center\">$quan</td>
<td align=\"center\">$price</td>
<td align=\"center\">\$$subtotal</td>
</tr>";
}
// Output
//
if ($orderdata) {
$output = "
<table width=\"600\" align=\"center\">
$orderdata
";
if ($products) {
$total = sprintf(("%.2f",$total);
$output .= "
<tr>
<td align=\"center\" color=\"#fff\" background=\"#000\">ITEM</td>
<td align=\"center\" color=\"#fff\" background=\"#000\">QUANTITY</td>
<td align=\"center\" color=\"#fff\" background=\"#000\">PRICE</td>
<td align=\"center\" color=\"#fff\" background=\"#000\">SUBTOTAL</td>
</tr>
$products
<tr><td colspan=\"3\" align=\"right\" color=\"#fff\" background=\"#000\">TOTAL:</td>
<td align=\"center\">\$$total</td>
</tr>
";
}
else { $output .= "<tr><td colspan=\"4\">OOPS no products!</td></tr>"; }
$output .= "</table><p> </p>";
}
//
else { output = "<p>Oops, no order data.</p>"; }
//
echo $output;