Re: Emailing a Database
| From: | Cody Caughlan | Date: | Tue, 10 Oct 2000 01:25:33 +0000 |
| Subject: | Re: Emailing a Database | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-3450@lists.php.net to get a copy of this message | ||
Basically, you just want to cycle through all the rows of your database,
grab the email adress and shove it in an array. Then, implode the array
with a comma as the delimiter, now a huge string containing your
addresses is ready to be sent in a message.
Like this:
$query = "SELECT emailAddress FROM yourTable";
$res = mysql_db_query("databaseName", $query);
$myArr = array();
while($row = mysql_fetch_array($res))
{
$str = $row[emailAddress];
array_push($myArr, $str);
}
$lineOfAddresses = implode(",", $myArr);
Mail($lineOfAddresses, "Your subject", "Your message"); //use a 4th arg
for extra headers (reply-to, etc)
Thats it.
/Cody Caughlan
Peter Burgess wrote:
> Hi There,
>
> I've created a database of customers and their email addresses
> in mySQL but have no idea how to email all those addresses.
> Could someone point me to some tutorials or render some advice.
> >From reading some resources I know that this can be achieved
> via perl but can php perform this function. Any advice would be
> welcomed.
>
> __,,_____________
> < ___________/
> / /-'
> /___/
>
> Peter Burgess
> m2o Designs
> 151 Greville Street Prahran 3181
> Melbourne Australia
> Ph: 03 9521 2553
> Fx: 03 9529 4712
> EM: peter@m2o.com.au
> URL:http://www.m2o.com.au
>