[HOW TO?] Mass Email from DB
Posted: Tue Dec 14, 2004 7:29 pm
I made a maillist db and php script and was wondering how to do a mass E-Mail.. heres the code for the maillist.php
can someone code or tell me how to code a mass email script for all the email address's in the db? thx
Code: Select all
<?php
error_reporting(E_ALL);
$valid = array(
'id', 'email'
);
$id = empty($_GET['id']) ? 'id' : $_GET['id'];
if(in_array($id, $valid)){
mysql_connect ("localhost", "steve_maillist", "maillist") or die(mysql_error());
mysql_select_db ('steve_maillist') or die(mysql_error());
$sql = 'SELECT * FROM maillist ORDER BY '.$id;
$result = mysql_query($sql) or die(mysql_error());
} else {
echo 'Invalid id: '.$_GET['id'];
}
echo "<table width="100%" border="1" cellspacing="0" cellpadding="0">";
echo "<tr>";
echo "<td width="25%"><b><a href="" . $_SERVER['PHP_SELF'] . "?id=id">ID</a> </b></td>\n";
echo "<td width="25%"><b><a href="" . $_SERVER['PHP_SELF'] . "?id=email">EMAIL</a></b></td>\n";
echo "</tr>";
while ($data = mysql_fetch_assoc($result)) {
echo "<tr>";
echo "<td>";
echo $data["id"];
echo "</td>";
echo "<td>";
echo $data["email"];
echo "</td>";
echo mysql_error();
}
echo "</table><br><BR><BR><BR>";
?>