So I'm using PHP like this:
if(isset($userID)) {
$premium = $con->prepare("
SELECT Email
FROM tblName as d
WHERE Rank = $rank and Type = $type
");
$premium->execute();
$premium->bind_result($email);
} else {
echo "There is no User ID detected, try to refresh browser.";
}
while ($premium->fetch()) {
# SUBJECT (Subscribe/Remove)
$subject = "New Resume";
# RESULT PAGE
$location = "http://www.website.com";
$sender = "info@website.com";
# MAIL BODY
$message = '<html><body>';
$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$message .= "</table>";
$message .= "</body></html>";
$cc = "ss@gmail.com";
$headers = "From: " . $sender . "
";
$headers = "BCC: " . $cc . "
";
$headers .= "Reply-To: ". strip_tags($_POST['Email']) . "
";
$headers .= "MIME-Version: 1.0
";
$headers .= "Content-Type: text/html; charset=ISO-8859-1
";
$to = $email;
mail( $to, $subject, $message, $headers) or die ("Mail could not be sent.");
}
header("Location: http://website.com/");
die();
mysqli_close($link);
But this not sending email for each selected users. How correctly I could use loop? Should I use foreach
or improve while
loop? How could I apply with arrays
in this case? Could someone get me on correct way? Thank you!