Hello everybody,
I'm working on a PHP newsletter system for my website.
As people subscribe for the newsletter, they need to choose their fields of interest from a list of 5. They need to pick at least 1 interest, but can also pick all 5.
If a newsletter is sent, there is a text that everybody gets, no matter what interest they signed up for. After that, there is a text for every different interest.
A small example: if somebody is signed up for interest 1 and 5, they need to get the general text, the text for interest 1 and the text for interest 5.
I hope I made clear what I want to do.
Here is the code I have so far:
I think there is something wrong with the way the e-mailaddresses are fetched from the database. I have 3 addresses in my test-database, but only 1 e-mail is sent.
I'm not at all a PHP-expert so the fault can be somewhere else as well.
Can somebody help me out here? That would be great!
Many thanks,
Michael Roos
Holland
I'm working on a PHP newsletter system for my website.
As people subscribe for the newsletter, they need to choose their fields of interest from a list of 5. They need to pick at least 1 interest, but can also pick all 5.
If a newsletter is sent, there is a text that everybody gets, no matter what interest they signed up for. After that, there is a text for every different interest.
A small example: if somebody is signed up for interest 1 and 5, they need to get the general text, the text for interest 1 and the text for interest 5.
I hope I made clear what I want to do.
Here is the code I have so far:
Code:
$query="SELECT personen.persoon_id, personen.email, interesse_persoon.interesse_id FROM personen JOIN interesse_persoon
ON personen.persoon_id = interesse_persoon.persoon_id ORDER BY persoon_id";
$res=mysql_query($query);
while($sendemail=mysql_fetch_array($res)){ [COLOR=red]//I think there is something wrong in this line[/color]
$lastid="";
$to = $sendemail["email"];
$from = "Michael Roos<m.roos@proeducation.nl>";
$subject = $mail->onderwerp->GetText();
$message[0]= $mail->tekst->GetText(); [COLOR=red]//This text is ment for everybody on the list[/color]
$message[1]= $mail->tekst1->GetText(); [COLOR=red]//This text is only ment for people with interest1[/color]
$message[2]= $mail->tekst2->GetText(); [COLOR=red]//This text is only ment for people with interest2[/color]
$message[3]= $mail->tekst2->GetText(); [COLOR=red]//This text is only ment for people with interest3[/color]
$message[4]= $mail->tekst2->GetText(); [COLOR=red]//This text is only ment for people with interest4[/color]
$message[5]= $mail->tekst2->GetText(); [COLOR=red]//This text is only ment for people with interest5[/color]
$headers = "From: $from\nReply-To: $from\nContent-Type: text/html";
while(mysql_num_rows($res) && $row=mysql_fetch_array($res)){
if($lastid <> $row["persoon_id"] && $lastid <> "") mail ($to, $subject, "$message[0]<p>$suffix", $headers);
$suffix.="<P>".$message[$row["interesse_id"]];
$lastid=$row["persoon_id"];
}
}
I think there is something wrong with the way the e-mailaddresses are fetched from the database. I have 3 addresses in my test-database, but only 1 e-mail is sent.
I'm not at all a PHP-expert so the fault can be somewhere else as well.
Can somebody help me out here? That would be great!
Many thanks,
Michael Roos
Holland