Hi all:
I am running a WHILE LOOP. I want to place a portion of the LOOP inside the body of a PHP EMAILER email.
while($rowItems = mysqli_fetch_array($resultItems, MYSQLI_ASSOC)){
if (($rowItems["listingRequired"] == 'Y') && ($rowItems["pdID"] != '15')){
$vDiscounted = ": Discounted Rate";
} else {
$vDiscounted = "";
}
$rQuantity = $rowItems["quantity"];
$rProduct = $rowItems["product"];
$vTotalItem = number_format($rowItems["quantity"]*$rowItems["price"],2);
$vTotal = $vTotalItem+$vTotal;
$vItemLoop .= "<tr><td style='width:80%; text-align:left;'>".$rQuantity." ".$rProduct." ".$vDiscounted."</td><td style='width:20%; text-align:right;'>$".$vTotalItem."</td></tr>\r\n";
}
And the body is:
$body = "
<div style='width:700px; border:1px solid #CCCCCC; padding:10px; margin:auto; font-family:calibri; font-size:17px;'>
".$vPaymentTypeText."
".date("n/j/Y")."
<p>
Invoice Number: ".$pInvoice."
<p>
<table style='width:700px; font-size:14px;'>
<tr><td colspan='2' style='width:100%; line-height: 25px; font-weight: bold; height: 25px; background-color:#FFCC00; margin-left: auto; margin-top: 10px; padding-left: 5px;'>Order Information:</td></tr>
".$vItemLoop."
<tr><td colspan='2'><hr style='width:98%;' /></td></tr>
<tr style='font-weight:bold; background-color:#EFEFFF'><td style='width:80%;'>Total:</td><td style='width:20%; text-align:right;'>$".number_format($pTotalTax, 2)."</td></tr>
</table>
</div>
";
The email is working fine. It is appearing just as expected. But the problem is, I am running this as an include on a different page. When run as above (where it is working fine) I get the following index message:
Notice: Undefined variable: vItemLoop in C:\Web\MySite\shp\shpInvoiceEmail.php on line 62
Line 62 corresponds to ".$vItemLoop." in the email "body". Now, when I change the code the WHILE portion from "$vItemLoop .=" to "$vItemLoop =" the error disappears, but as expected, all my line items do not appear in the email.
If anyone could point out what I am doing wrong it would be appreciated!