php电子邮件函数不发送while循环的记录
这是我的email.php页面编码。我的php电子邮件功能代码工作得很好。我在这里面临一个小问题。当($t\u row=mysql\u fetch\u数组($tarrium\u query)){}时,我没有在php电子邮件函数不发送while循环的记录,php,mysql,email,Php,Mysql,Email,这是我的email.php页面编码。我的php电子邮件功能代码工作得很好。我在这里面临一个小问题。当($t\u row=mysql\u fetch\u数组($tarrium\u query)){}时,我没有在中获取数据库记录。但是,它正确地从数据库发送剩余记录。如何在($t\u row=mysql\u fetch\u数组($tarrium\u query)){}时发送中的数据库记录 include("config.php"); if(isset($_GET["id"])) {
中获取数据库记录。但是,它正确地从数据库发送剩余记录。如何在($t\u row=mysql\u fetch\u数组($tarrium\u query)){}
时发送中的数据库记录
include("config.php");
if(isset($_GET["id"]))
{
$id = mysql_real_escape_string($_GET["id"]);
$query = mysql_query("SELECT * FROM ebvouchers WHERE VoucherID = $id");
$row = mysql_fetch_object($query);
echo mysql_error();
$tariff_query = mysql_query("SELECT * FROM ebvouchertariffs WHERE VoucherID_Fk = $id");
$strMessage = "<table width=1200 align=center cellpadding=0 cellspacing=0 bgcolor=#FFFFFF>
<tr>
<td width=1026 height=8 colspan=2> </td>
</tr>
<tr>
<td colspan=8>
<table class=glow width=1070 border=0 align=center cellpadding=0 cellspacing=0>
<tr>
<td height=40 colspan=4 style=border-radius: 5px 5px 0px 0px; class=headdetail>GUEST DETAILS </td>
</tr>
<tr>
<td width=263 height=10 class=detailsfont> </td>
<td width=228> </td>
<td width=239 class=detailsfont> </td>
<td width=340> </td>
</tr>
<tr>
<td height=40 class=detailsfont>Voucher ID :</td>
<td width=228 class=fetchfont>$row->VoucherID</td>
<td width=239 class=detailsfont>Voucher Reference Number :</td>
<td width=340 class=fetchfont>$row->VoucherReference</td>
</tr>
//some codes
//some codes
//some codes
//some codes
//some codes
//some codes
//some codes
<tr>
<td colspan=4>
<table class=myborder width=1050 border=0 align=center cellpadding=10 cellspacing=0>
<tr>
<td width=70 height=40 class=tarifffont>Serial No</td>
<td width=130 class=tarifffont>Date</td>
<td width=250 class=tarifffont>Particulars</td>
<td width=100 class=tarifffont>No of Nights</td>
<td width=100 class=tarifffont>Rate</td>
<td width=100 class=tarifffont>Price</td>
<td width=100 class=tarifffont>Tax %</td>
</tr>";
while($t_row = mysql_fetch_array($tariff_query))
{
"<tr>
<td class=insidetariff>". $t_row['TariffSlNo'] ."</td>
<td class=insidetariff>". $t_row['TariffDate'] ."</td>
<td class=fetchfont>". $t_row['TariffParticulars'] ."</td>
<td class=insidetariff>". $t_row['NoOfNights'] ."</td>
<td class=insidetariff>". $t_row['TariffRate'] ."</td>
<td class=insidetariff>". $t_row['TariffPrice'] ."</td>
<td class=insidetariff>". $t_row['TariffTax'] ."</td>
</tr>";
}
"<tr>
<td height=40 colspan=2 class=detailsfont>Total Price (Overall Price) : </td>
<td height=20 colspan=2 class=tarifffont>$tt_row->TariffAddTotal</td>
<td height=20 class=insidetariff>Net Total (Overall Tax) : </td>
<td height=20 colspan=2 class=tarifffont>$tt_row->TariffNetTotal</td>
</tr>
<tr>
<td height=20 colspan=7 class=detailsfont> </td>
</tr>
<tr>
<td height=40 colspan=5 class=detailsfont>Final Amount : </td>
<td height=40 colspan=2 class=tarifffont>$tt_row->TariffFinalTotal</td>
</tr>
</table></td>
</tr>
<td colspan=4> </td>
</table>
</td>
</tr>";
}
include(“config.php”);
如果(isset($\u GET[“id”]))
{
$id=mysql\u real\u escape\u字符串($\u GET[“id”]);
$query=mysql\u query(“从凭证中选择*,其中VoucherID=$id”);
$row=mysql\u fetch\u对象($query);
echo mysql_error();
$tarriff\u query=mysql\u query(“从ebvouchertarties中选择*,其中VoucherID\u Fk=$id”);
$strMessage=”
客人详细信息
凭证ID:
$row->VoucherID
凭证参考号:
$row->VoucherReference
//一些代码
//一些代码
//一些代码
//一些代码
//一些代码
//一些代码
//一些代码
序列号
日期
详情
夜数
比率
价格
税%
";
而($t\u row=mysql\u fetch\u数组($tary\u query))
{
"
“$t_行['TariffSlNo']”
“$t_行['TariffDate']”。”
“$t_行['TariffDetails']
“$t_row['NoOfNights']”
“$t_行['TariffRate']
“$t_行['TariffPrice']”。”
“$t_row['TariffTax']”
";
}
"
总价(总价):
$tt_行->TariffAddTotal
净总额(总税):
$tt_row->净关税总额
最终金额:
$tt_row->TariffFinalTotal
";
}
必须将数据附加到字符串中。因此,代码如下所示:
while ($t_row = mysql_fetch_array($tariff_query)) {
$strMessage .= "<tr>
<td class=insidetariff>". $t_row['TariffSlNo'] ."</td>
<td class=insidetariff>". $t_row['TariffDate'] ."</td>
<td class=fetchfont>". $t_row['TariffParticulars'] ."</td>
<td class=insidetariff>". $t_row['NoOfNights'] ."</td>
<td class=insidetariff>". $t_row['TariffRate'] ."</td>
<td class=insidetariff>". $t_row['TariffPrice'] ."</td>
<td class=insidetariff>". $t_row['TariffTax'] ."</td>
</tr>";
}
$strMessage .= "<tr>
<td height=40 colspan=2 class=detailsfont>Total Price (Overall Price)....
$tbl = '';
while($t_row = mysql_fetch_array($tariff_query))
{
$tbl .= "<tr>
<td class=insidetariff>". $t_row['TariffSlNo'] ."</td>
<td class=insidetariff>". $t_row['TariffDate'] ."</td>
<td class=fetchfont>". $t_row['TariffParticulars'] ."</td>
<td class=insidetariff>". $t_row['NoOfNights'] ."</td>
<td class=insidetariff>". $t_row['TariffRate'] ."</td>
<td class=insidetariff>". $t_row['TariffPrice'] ."</td>
<td class=insidetariff>". $t_row['TariffTax'] ."</td>
</tr>";
}
while($t\u row=mysql\u fetch\u数组($tary\u query)){
$strMessage.=”
“$t_行['TariffSlNo']”
“$t_行['TariffDate']”。”
“$t_行['TariffDetails']
“$t_row['NoOfNights']”
“$t_行['TariffRate']
“$t_行['TariffPrice']”。”
“$t_row['TariffTax']”
";
}
$strMessage.=”
总价(总价)。。。。
另外,不推荐使用mysql\u*
函数,将来将删除这些函数。现在应该使用mysqli\u*
函数。您走错了路。首先将while循环数据指定给变量,然后像这样添加到邮件消息中:
while ($t_row = mysql_fetch_array($tariff_query)) {
$strMessage .= "<tr>
<td class=insidetariff>". $t_row['TariffSlNo'] ."</td>
<td class=insidetariff>". $t_row['TariffDate'] ."</td>
<td class=fetchfont>". $t_row['TariffParticulars'] ."</td>
<td class=insidetariff>". $t_row['NoOfNights'] ."</td>
<td class=insidetariff>". $t_row['TariffRate'] ."</td>
<td class=insidetariff>". $t_row['TariffPrice'] ."</td>
<td class=insidetariff>". $t_row['TariffTax'] ."</td>
</tr>";
}
$strMessage .= "<tr>
<td height=40 colspan=2 class=detailsfont>Total Price (Overall Price)....
$tbl = '';
while($t_row = mysql_fetch_array($tariff_query))
{
$tbl .= "<tr>
<td class=insidetariff>". $t_row['TariffSlNo'] ."</td>
<td class=insidetariff>". $t_row['TariffDate'] ."</td>
<td class=fetchfont>". $t_row['TariffParticulars'] ."</td>
<td class=insidetariff>". $t_row['NoOfNights'] ."</td>
<td class=insidetariff>". $t_row['TariffRate'] ."</td>
<td class=insidetariff>". $t_row['TariffPrice'] ."</td>
<td class=insidetariff>". $t_row['TariffTax'] ."</td>
</tr>";
}
$tbl='';
而($t\u row=mysql\u fetch\u数组($tary\u query))
{
$tbl.=”
“$t_行['TariffSlNo']”
“$t_行['TariffDate']”。”
“$t_行['TariffDetails']
“$t_row['NoOfNights']”
“$t_行['TariffRate']
“$t_行['TariffPrice']”。”
“$t_row['TariffTax']”
";
}
现在在您的消息中添加如下变量:
$strMessage = "<table>.....".$tbl."....";
$strMessage=“…”$tbl.“…”;
您没有连接变量$strMessage
的字符串
在while
循环中,您应该将字符串与变量连接起来,最后echo
它。将while循环中计算的数据存储为:
while($t_row = mysql_fetch_array($tariff_query))
{
$strMessage .= "<tr>
<td class=insidetariff>". $t_row['TariffSlNo'] ."</td>
<td class=insidetariff>". $t_row['TariffDate'] ."</td>
<td class=fetchfont>". $t_row['TariffParticulars'] ."</td>
<td class=insidetariff>". $t_row['NoOfNights'] ."</td>
<td class=insidetariff>". $t_row['TariffRate'] ."</td>
<td class=insidetariff>". $t_row['TariffPrice'] ."</td>
<td class=insidetariff>". $t_row['TariffTax'] ."</td>
</tr>";
}
while($t\u row=mysql\u fetch\u数组($tary\u query))
{
$strMessage.=”
“$t_行['TariffSlNo']”
“$t_行['TariffDate']”。”
“$t_行['TariffDetails']
“$t_row['NoOfNights']”
“$t_行['TariffRate']
“$t_行['TariffPrice']”。”
“$t_row['TariffTax']”
";
}
并将while循环后的字符串分配给$strMessage:
$strMessage .= "<tr>
<td height=40 colspan=2 class=detailsfont>Total Price (Overall Price) : </td>
<td height=20 colspan=2 class=tarifffont>$tt_row->TariffAddTotal</td>
<td height=20 class=insidetariff>Net Total (Overall Tax) : </td>
<td height=20 colspan=2 class=tarifffont>$tt_row->TariffNetTotal</td>
</tr>
<tr>
<td height=20 colspan=7 class=detailsfont> </td>
</tr>
<tr>
<td height=40 colspan=5 class=detailsfont>Final Amount : </td>
<td height=40 colspan=2 class=tarifffont>$tt_row->TariffFinalTotal</td>
</tr>
</table></td>
</tr>
<td colspan=4> </td>
</table>
</td>
</tr>";
$strMessage.=”
总价(总价):
$tt_行->TariffAddTotal
净总额(总税):
$tt_row->净关税总额
最终金额:
$tt_row->TariffFinalTotal
";
谢谢..这很有效..我是一名初学者..如何使用mysqli,pdo函数代替mysql。为我提供一些有用的链接..@Indian,很高兴它成功了。这是关于mysqli的一些信息。这是另一个stackoverflow问题,答案非常简单,描述了基本需求。