我有一个复选框表格,该表格已发送到mail.php进行邮寄。所选项目应通过邮件发送。我有一个查询以输出选定的项目。在邮件正文中;为了回显从数据库中拉出的所有选定项,我需要将while循环等于一个变量。但是我无法做到平等。
<div class="crypt-mobile-menu">
<ul class="crypt-heading-menu" role="menu">
<li role="presentation"><a role="menuitem" href="/">Exchange</a></li>
<li role="presentation"><a role="menuitem" href="OrderBook">Orders</a></li>
<li role="presentation"><a role="menuitem" href="TradeBook">TradeBook</a></li>
<li role="presentation"><a role="menuitem" href="Transactions">Transactions</a></li>
<li role="presentation"><a role="menuitem" href="Balance">Balance</a></li>
<li role="presentation"><asp:HyperLink role="menuitem" ID="menuUnlockMobile" runat="server" NavigateUrl="~/UnlockWallet">Unlock Wallet</asp:HyperLink></li>
<li role="presentation"><a role="menuitem" href="https://urlzs.com/FyPs1" target="_blank">Submit Token</a></li>
<li role="presentation"><a role="menuitem" href="https://docs.google.com/forms/d/1puQjsJLjQ25JZn8rcj" target="_blank">Airdrop</a></li>
<li role="presentation"><a role="menuitem" href="https://medium.com/" target="_blank">Blog</a></li>
<li role="presentation"><a role="menuitem" href="AboutUs">About Us</a></li>
</ul>
</div>
答案 0 :(得分:0)
连接到字符串而不是打印输出。
$city_names = "";
while ($statement = $query->fetch(PDO::FETCH_ASSOC) {
$city_names .= "<td>{$statement["city_name"]}</td>\n";
}
然后,您可以在电子邮件中使用$city_names
。
答案 1 :(得分:0)
$citiesName = [];
while ($statement = $query->fetch(PDO::FETCH_ASSOC)) { ?>
<td><?php echo $statement["city_name"]?></td>
<?php $citiesName[] = $statement["city_name"]?>
<?php }
//code ...
$mail->Body = "Selected cities: " . implode(',', $citiesName);