【发布时间】:2014-02-17 12:28:16
【问题描述】:
我正在尝试在电子邮件中发送数组数据,但无法让这个东西正常工作。 这是确切的代码。
$c = mysql_query("SELECT item,qty,price,uom FROM saleitems WHERE saleinvid = '222384' ");
$to = "email@domain.com";
$subject = "Invoice from company";
$headers = "Content-type: text/html\r\n";
$message = 'Greetings,
you are receiving this email as an invoice as follows:
<table border="1">
<tr>
<td>Description</td>
<td>Quantity</td>
<td>Price</td>
<td>UOM</td>
</tr>
';
while ($row = mysql_fetch_array($c)){
$message .="<tr>";
$message .="<td>".$row['item']."</td>";
$message .="<td>".$row['qty']."</td>";
$message .="<td>".$row['price']."</td>";
$message .="<td>".$row['uom']."</td>";
$message .="</tr>";
}
$message .="</table>Thank You,COMPANY";
mail($to,$subject,$message,$headers);
邮件已发送,但我看到的只是表格标题行和“谢谢您,公司”行,但中间没有任何项目。任何帮助是极大的赞赏。 我的电子邮件提供商支持 HTML 消息
【问题讨论】:
-
您确定您的电子邮件提供商支持 html 吗?
-
首先,从代码中删除“打印”调用。
-
请检查您的查询是否有返回的行数错误,然后返回此处打印您的结果。