如何编辑此代码,以便每个数据都采用表格格式,在指定列下,例如Sname
将在商店名称下,pname
将在产品名称下。谢谢
$list = '';
$pplresult = mysql_query("SELECT * FROM repplac");
while($row = mysql_fetch_assoc($pplresult)){
$list .= $row['Sname'] .$row['Pname'] .$row['Psize'] .$row['Pcolour'] .$row['Pquantity'] .$row['Price']."\n";
}
//Send email
$to = $email;
$subject = "YOUR ORDER LIST FROM REACHEASY";
$headers = "From: donotreply@rapsody.co.uk";
$body = "$list";
mail($to,$subject,$body,$headers);
非常感谢。
答案 0 :(得分:1)
答案 1 :(得分:0)
这可能是一个简单的例子。
$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>
</tr>";
$pplresult = mysql_query("SELECT * FROM repplac");
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>
</tr>";
}
$body .="</table></body></html>";
//Send email
$to = $email;
$subject = "YOUR ORDER LIST FROM REACHEASY";
$headers = "From: donotreply@rapsody.co.uk\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($to,$subject,$body,$headers);