任何人都可以幫我這個
郵件列表在PHP
SELECT USEREMAIL從MySQL用戶得到一個電子郵件列表像
USEREMAIL
[email protected]
b @ gmail.com
目前$ USEREMAIL得到第一封電子郵件從列表
[email protected]
我試圖從數據庫中獲取的郵件列表像
一個@ gmail.com,B @ gmail.com
<?php
$mailselect = "SELECT userEmail FROM users";
$mailselect2 = mysqli_query($mysqli, $mailselect) or die('-31' . mysqli_error());
$recipients = mysqli_fetch_assoc($mailselect2);
$userEmail = $recipients['userEmail'];
$recipientss = array(',', $row['recipients']);
$to = '[email protected]';
$subject = "E-mail subject";
$message = 'Testing1: ' . $userEmail . "\n" .
'Testing2: ' . implode(',', $recipientss);
$headers = 'From: [email protected]' . "\r\n" ;
$headers .= 'Reply-To: [email protected]' . "\r\n";
mail($to, $subject, $message, $headers);
?>
目前mail()函數發送此郵件 Testing1:一個@ gmail的.com Testing1:
implode(',',$ recipient);這段代碼可能是個問題。 任何人有一些消化不良
謝謝你們。
你從哪裏得到$行? –
您只得到結果的第一行,您需要通過在'$ recipients'上使用'while'循環來解析查詢的所有結果。或者,你可以查詢「GROUP_CONCAT(userEmail)」而不是'userEmail',這會給你所有的結果。 – roberto06
@Bikash對不起$ recipients = mysqli_fetch_assoc($ mailselect2)的$收件人; – Guru