我目前使用下面的代碼從php中的mysql表郵寄數據,它使用下面的代碼,它完美的工作,但問題是它發送每行數據作爲一個單一的郵件,我想發送一個郵件中的所有數據行,如何合併所有數據行並將其作爲單個郵件發送?請幫幫我!!如何將所有數據通過電子郵件發送到一個郵箱?
<?php
include('header.php');
session_start();
?>
<html>
<head>
<title>Sending email using PHP</title>
</head>
<body>
<?php
$sql="SELECT * FROM products";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)){
$to = "[email protected]";
$subject = "d2dn-viewcart";
$id_s = $row["id"];
$name_s = $row["description"];
$price_s = $row["price"] ;
$message = $id_s . " " . $name_s . " " . $price_s." ";
$header = "From:d2dn";
$retval = mail ($to,$subject,$message,$header);
}
if($retval == true)
{
echo "Message sent successfully...";
}
else
{
echo "Message could not be sent...";
}
?>
</body>
</html>
<?php
include('footer.php'); ?>
你會發現,如果'($重估)'是** **完全相同一樣'如果($ RETVAL ==真)'和更快的輸入。 – zanderwar 2014-12-02 07:31:42