I got a script which has to send people personized mail.
And although I am almost finished it (i hope) I got the problem with the while loop.
Yes, with this script everyone in the MYSQL database gets mail, but number two in the list got except for their variabels also the var. of other persons, like..
Dear Sir Johnson,
new on our site is....
And the next person gets:
Dear Sir Johnson, Dear madame Jameson,
new on our site is....
How do I have to change this while loop?
every help is appreciated.
Thanks
<?
//connect
@ $db = mysql_connect('localhost', 'user', 'password');
if (!db)
{
echo 'Error: Kon geen connectie met de database maken. Probeert u het later nog eens.';
exit;
}
mysql_select_db("mailing");
$result = mysql_query ("select gender, lastname, mailadres from unieke_mailinglist");
if (!$result) {
die('Could not query:' . mysql_error());
}
while ($row = mysql_fetch_array($result))
{
$potklant_id = $row['potklant_id'];
$geslacht = $row['gender'];
$achternaam = $row['lastname'];
$mailadres = $row['mailadres'];
if ($gender == "m")
{
$geslacht = "sir";
}
else
{
$gender = "madame";
}
$STRcontent = "Dear".$gender." ".$achternaam."<br/>
new on our site is.... <br/>
And we are pleased to...";
$body .= " <html><head><title>Bordeaux primeurs 2003</title></head> \n";
$body .= " <body bgcolor=\"#FFFFCC\" text=\"#0000FF\"><font face='verdana' size='2'> \n";
$body .= $STRcontent;
$body .= " </body>";
$body .= " </html>";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
if ($STRinviter == "") {
$STRinviter = "Van Mij";
}
if ($STRfrom == "") {
$STRfrom = "ikke@hccnet.nl";
}
$headers .= "From: ".$STRinviter." <".$STRfrom.">\r\n";
$STRlink = " <br>click the following link for the details:<br><a target='_blank' href='http://www.site.nl/page.html'>to page</a> \n";
mail($mailadres, "Nieuwsbrief", $body.$STRlink, $headers);
}
if(!$result)
{
echo "<p align=center><b>Update not sent</b> ", mysql_error();
exit;
}
if($result)
{
mysql_close($db);?>
<?
print "<html><head><title>Bordeaux Primeurs 2003</title><link REL='STYLESHEET' HREF='css/sfx.css' TYPE='text/css'></head><body onLoad='setTimeout(window.close, 1000)'>";
print "<p align=center>Your Update has been sent to everyone</p>";
print "</body></html>";
}
?>😃