我正在使用以下查询:-
$qry=mysql_query("SELECT item,quantity,price,(quantity * price) as total FROM saleitems_T WHERE invoice = '$inv' ");
我试图在邮件正文中使用while循环,但它不起作用。以下是代码。
$to="someone@somewhere.com";
$headers="Content-type: text/html'r'n";
$body = '
<html> <body>
Invoice details are as follows.<br />
'.while($row = mysql_fetch_array($qry)){
echo "<table><tr><td>";
echo $row['item'];
echo "</td><td>";
echo $row['quantity'];
echo "</td><td>";
echo $row['price'];
echo "</td><td>";
echo $row['total'];
echo "</td></tr>";} .'
</table></body></html>';
mail($to,$body,$headers);
检索到的行数因每张发票而异。现在我想把结果作为电子邮件发送。对示例代码的任何帮助都将不胜感激。
$to = "someone@somewhere.com";
$headers = "Content-type: text/html'r'n";
$body = '<html><body>Invoice details are as follows.<br />';
foreach( mysql_fetch_array($qry) as $v ) {
$body .= "<table><tr><td>{$v['item']}</td>"
. "<td>{$v['quantity']}</td>"
. "<td>{$v['price']}</td>"
. "<td>{$v['total']}</td></tr></table></body></html>";
}
mail($to,$body,$headers);