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: Select all
$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)){ //I think there is something wrong in this line
$lastid="";
$to = $sendemailї"email"];
$from = "Michael Roos<m.roos@proeducation.nl>";
$subject = $mail->onderwerp->GetText();
$messageї0]= $mail->tekst->GetText(); //This text is ment for everybody on the list
$messageї1]= $mail->tekst1->GetText(); //This text is only ment for people with interest1
$messageї2]= $mail->tekst2->GetText(); //This text is only ment for people with interest2
$messageї3]= $mail->tekst2->GetText(); //This text is only ment for people with interest3
$messageї4]= $mail->tekst2->GetText(); //This text is only ment for people with interest4
$messageї5]= $mail->tekst2->GetText(); //This text is only ment for people with interest5
$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'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
Code: Select all