Code: Select all
$emails = $_POST['emails'];
$email_ar = split('[;,]', $emails);
I create a foreach loop and an if/else statement to decifer between "group" emailing lists and single addresses like so:
Code: Select all
foreach($email_ar as $email) {
if(!stristr($email, "@")) { //GROUP MAILING LIST
$result = mysql_query("SELECT * FROM `newsalert` WHERE `group`='$email'");
while($row = mysql_fetch_array($result)) {
sendMail($row['email']);
}
} else { //SINGLE ADDRESS
sendMail($email);
}
}
Code: Select all
function sendMail($emailaddy) {
echo $emailaddy . "<br />";
}
Wierd thing is that the foreach loop only processes the first array element. If it is a group it will correctly echo out all emails associated with the group and nothing more. Same if the first array element is a single address. It echoes only one address and then stops.
There is no other php code on the page other than a db connection script. The array split works fine. I've used print_r($email_ar) which prints: Array ( [0] => group1 [1] => group2 [2] => test@testing.com ).
So I'm thinking, and I could be very wrong here, that it's a return true/false thing (???). But after hours and days working on this script I'm about ready to throw my computer out the window!!
Please Help!! My computer is too young to go now, she still has a lot in her...
THANKS! -Jeff