Joe wrote:
I want to select a bunch of email addresses from a mysql table and format
them to use with a php mail() function. I can select them from the database,
but how do I format them so there's a comma and space after every one?
Don't do that! :)
You're saying you'd like one big-ass To: field? Kinda like To:
yo*@test.com,
me@test.com,
fr***@test.com?
Use a loop.
$result = mysql_query("SELECT email FROM tblEmail");
while($row = mysql_fetch_array($result)) {
mail($row['email'],$subject,$message,"From:yo*@test.com\r\n");
}
------------------------------------
Even though you shouldn't, here's how to format them the way you asked:
$result = mysql_query("SELECT email FROM tblEmail");
while($row = mysql_fetch_array($result)) {
$to = $to . $row['email'] . ", ";
}
And then just remove the last ", " from the string and call the mail
function once. But that would be icky.
--
Sugapablo
------------------------------------
http://www.sugapablo.com <--music
http://www.sugapablo.net <--personal