【发布时间】:2015-03-06 01:50:46
【问题描述】:
我正在尝试发送用户从我的网站订购的产品列表..我能够发送电子邮件,但产品列表仅显示数组..任何帮助将不胜感激。谢谢:)
这是我获取产品列表的 sql:
$data = array();
$sql = mysql_query("select oi.id ,oi.quantity, p.code, p.name from order_items oi left join product p on p.id = oi.product_id where order_id = $orderID ");
$result = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
$code = ($result['code'] != "") ? $result['code'] : $result['name'];
$quantity = $result['quantity'];
$data[] = ''.$code.' - '.$quantity.'';
//$content2 = implode("<br>", $data);
}
电子邮件部分:
$mail_content .= '<table id="mytable" cellspacing="0" style="">';
$mail_content .= '<tr >';
$mail_content .= '<td width="20%">product</td>';
$mail_content .= '<td width="20%">Unit Type</td>';
$mail_content .= '<td width="10%">Quantity</td>';
$mail_content .= '</tr>';
$mail_content .= '<tr>';
$mail_content .= "<td>";
$mail_content .= "$data";
$mail_content .= "</td>";
$mail_content .= '<td width="20%">Unit Type</td>';
$mail_content .= '<td width="10%">Quantity</td>';
$mail_content .= '</tr>';
$mail_content .= '</table>';
【问题讨论】:
-
因为 $data 是一个你想要循环遍历的数组(
foreach()是一个不错的选择)