Mysql 邮件消息中的数组和变量
我有以下问题。我喜欢有一些行,在消息正文中最多10行。我从数据库中获取的行。我怎么能做到?这是我的代码。通过echo,我得到了“行”,但我如何将其放入变量中,我喜欢在邮件正文中使用Mysql 邮件消息中的数组和变量,mysql,email,message,Mysql,Email,Message,我有以下问题。我喜欢有一些行,在消息正文中最多10行。我从数据库中获取的行。我怎么能做到?这是我的代码。通过echo,我得到了“行”,但我如何将其放入变量中,我喜欢在邮件正文中使用 mysql_query("SET NAMES 'utf8'"); $sql = "SELECT * FROM multi_booking WHERE booking_no = '{$_GET['booking']}'";
mysql_query("SET NAMES 'utf8'");
$sql = "SELECT * FROM multi_booking WHERE booking_no = '{$_GET['booking']}'";
$ergebnis_sub = mysql_query($sql);
while ($row_sub = mysql_fetch_object($ergebnis_sub))
{
mysql_query("SET NAMES 'utf8'");
$sql1 = "SELECT * FROM multi_orders WHERE booking_no = '{$_GET['booking']}'";
$result = mysql_query($sql1);
$row_count = mysql_num_rows($result);
for($i = 1; $i <= $row_count; $i++)
{
$row = mysql_fetch_array($result);
echo("Service[$i]. {$row['Services']}\n");
}
$idbooking = $row_sub->idbooking;
$name = $row_sub->name;
$email = $row_sub->email;
$blang = $row_sub->lang;
$country = $row_sub->country;
$arrivaldate = $row_sub->arrivaldate;
$accommodation = $row_sub->accommodation;
$totalamount = $row_sub->totalamount;
$invoice = $row_sub->invoice;
$comment = $row_sub->comment;
$message2 = "
Subject: Booking $invoice<br />
-----------------------------------------------------------------------------------------------------------<br />
Name: $name<br />
EMail: $email<br />
Language: $blang<br />
Country: $country<br />
Arrival Date: $arrivaldate<br />
Hotel: $accommodation<br />
Service 1: '$service[1]'<br />
Service 2: $service[2]<br />
Service 3: $service[3]<br />
Service 4: $service4<br />
Service 5: $service5<br />
Service 6: $service6<br />
Service 7: $service7<br />
Service 8: $service8<br />
Service 9: $service9<br />
Service 10: $service10<br />
Total amount: $totalamount<br />
Booking Invoice: $invoice<br />
Booking Comment: $comment<br />
-----------------------------------------------------------------------------------------------------------<br />
Please check in the admin section for the follow booking number: $invoice
";
}
mysql\u查询(“设置名称“utf8”);
$sql=“从多个预订中选择*,其中预订号=“{$\u GET['booking']}”;
$ergebnis\u sub=mysql\u查询($sql);
while($row\u sub=mysql\u fetch\u object($ergebnis\u sub))
{
mysql_查询(“设置名称‘utf8’”);
$sql1=“从多个订单中选择*,其中预订号=“{$\u GET['booking']}”;
$result=mysql\u查询($sql1);
$row\u count=mysql\u num\u rows($result);
对于($i=1;$i idbooking;
$name=$row\u sub->name;
$email=$row\u sub->email;
$blang=$row\U sub->lang;
$country=$row\u sub->country;
$arrivaldate=$row\u sub->arrivaldate;
$住宿=$row_sub->住宿;
$totalamount=$row\u sub->totalamount;
$invoice=$row\u sub->invoice;
$comment=$row\u sub->comment;
$message2=”
主题:预订$invoice
-----------------------------------------------------------------------------------------------------------
名称:$Name
电子邮件:$EMail
语言:$blang
国家:$Country
到达日期:$arrivaldate
酒店:住宿费
服务1:“$Service[1]”
服务2:$Service[2]
服务3:$Service[3]
服务4:$service4
服务5:$service5
服务6:$service6
服务7:$service7
服务8:$service8
服务9:$service9
服务10:$service10
总额:$totalamount
预订发票:$Invoice
预订评论:$Comment
-----------------------------------------------------------------------------------------------------------
请在管理部分查看以下预订号码:$invoice
";
}
您可以使用
运算符连接字符串,这样您就可以将它们像这样组合成一个变量
$lines = "";
for($i = 1; $i <= $row_count; $i++)
{
$row = mysql_fetch_array($result);
$lines = $lines . "Service[$i]. {$row['Services']}\n");
}
嗨,GolezTrol,就我所喜欢的而言。有可能在一行中得到“服务”吗?我不知道你的意思。目前我在我的电子邮件中得到了这个信息:服务:服务[1]:Koh Tao(fueraborda)/Pax:2/总计:9900服务[2]:Snowkel en Angthong海洋公园/Pax:2/总计:4600所有内容都在一行中。我更喜欢在两行中,或者取决于服务行的数量。啊。我认为您需要在for循环中添加一个
。目前,只有一个\n
,但在HTML邮件中,这不会显示出来。如果答案对您有帮助,您可以向上投票和/或接受这不是向未来的游客展示这个的答案。
$message2 = "
Subject: Booking $invoice<br />
-----------------------------------------------------------------------------------------------------------<br />
Name: $name<br />
EMail: $email<br />
Language: $blang<br />
Country: $country<br />
Arrival Date: $arrivaldate<br />
$lines
Total amount: $totalamount<br />
Booking Invoice: $invoice<br />
Booking Comment: $comment<br />";
$mystring = $mystring . 'x';
$mystring .= 'x';