2019-07-07 10:18
浏览 100


I have a checkbox form which is sent to mail.php to be mailed. The selected items should be sent via mail. I have a query to output selected items. In mail body; to echo all selected items which pulled from database, i need to equal the while loop to a variable. But i can not manage it to equal.

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';

include 'nedmin/netting/database.php';

if (isset($_POST['sendmail'])) {



$query = $db->prepare("SELECT * FROM semt WHERE semt_id IN('".$cities."')");


while ($statement = $query->fetch(PDO::FETCH_ASSOC)) {

   <td><?php echo $statement["city_name"]?></td>

<?php }

$mail = new PHPMailer;

try {
   /* SMTP parameters. */
   $mail->SMTPKeepAlive = TRUE;   
   $mail->SMTPAuth = TRUE;
   $mail->SMTPSecure = 'tls';

   $mail->Subject = "Subject";
   $mail->Body = "Selected cities: $......";

catch (Exception $e)
   echo $e->errorMessage();
catch (\Exception $e)
   echo $e->getMessage();

2条回答 默认 最新

相关推荐 更多相似问题