i have a code that send two emails to different people but the first mail sends the right total amount, while the message to the second email(los@yahoo.ca) adds up the total amount twice and sends it.please how can i fix it
$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>";
$totalPrices += $row['Tprice'];
}
if(0.1*$totalPrices <= 50 )
{
$totalprice = (0.1*$totalPrices + $totalPrices);
}
else
{
$totalprice = 50 + $totalPrices;
}
$body .= "<tr>
<td colspan=6>Total :</td>
<td>" . $totalprice ."</td>
</tr>";
$body .="</table></body></html>";
//Send email
$to = $email;
$subject = "YOUR ORDER LIST($orderno) FROM REACHEASY";
$headers = "From: donotreply@easy.co.uk\\r\
"
. 'MIME-Version: 1.0' . "\\r\
"
. 'Content-type: text/html; charset=iso-8859-1' . "\\r\
"
. 'Bcc:notification@easy.co.uk' . "\\r\
";
mail($to,$subject,$body,$headers);
//Get list to managers user
$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>weblink</th>
<th>info</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['Weblink'] ."</td>
<td>" . $row['comment'] ."</td>
<td>" . $row['Price'] ."</td>
<td>" . $row['Tprice'] ."</td>
</tr>";
$totalPrices += $row['Tprice'];
}
if(0.1*$totalPrices <= 50 )
{
$totalprice = (0.1*$totalPrices + $totalPrices);
}
else
{
$totalprice = 50 + $totalPrices;
}
$body .= "<tr>
<td colspan=8>Total :</td>
<td>" . $totalprice ."</td>
</tr>";
$body .="</table></body></html>";
//Send email
$emails ="los@yahoo.ca";
$to = $emails;
$subject = "YOUR ORDER LIST($orderno) FROM REACHEASY";
$headers = "From: donotreply@easy.co.uk\\r\
"
. 'MIME-Version: 1.0' . "\\r\
"
. 'Content-type: text/html; charset=iso-8859-1' . "\\r\
"
. 'Bcc:notification@easy.co.uk' . "\\r\
";
mail($to,$subject,$body,$headers);