Reputation:
<?php include("admin/db.php");
$recipients = "SELECT * FROM recipients ORDER BY id DESC";
$email_list = $db->query($recipients);
foreach($email_list as $row) {
echo $row['email'].",";
}
$to = "?";
?>
Above I have a comma delimitated list of emails which I need to insert into the $to variable. How do I do this?
Upvotes: 0
Views: 3884
Reputation: 41
$recipients = "SELECT * FROM recipients ORDER BY id DESC";
while ($row = mysql_fetch_array($recipients))
{
$adresses[] = $row['email'];
}
$to = implode(",",$adresses);
Upvotes: 1
Reputation: 6865
foreach($email_list as $row) {
echo $row['email'].",";
mail($row['mail'], $subject, $body)
}
Upvotes: 0