CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Problem with mailsystem

Print topic Send  topic

Author Message
Michael
Posted: 04/14/2004, 6:34 AM

Hello everybody,

I'm working on a CCS/PHP4/MySQL mailinglist system.
People can subscribe for the list, and can choose their areas of interest. There's a minimum of 1 and a maximum of 5 interests.

I allready have the main mailingsystem working, but I want it a little more complex.
I've seperated the mailform into 6 sections, the first one for general news that everybody gets, the second one for interest 1, the third one for interest 2, etc.

Now I want my recipients just to receive the information for the interests they've signed up for. So somebody who signed up for interest 2 and 5 should recieve the general part, and the parts for 2 and 5.

This is the bit of code I allready have, but I think I'm completely out of direction...

$query_tekst = "SELECT personen.persoon_id, interesse_persoon.interesse_id FROM interesse_persoon, personen WHERE interesse_persoon.persoon_id = '$id'";  
$txt_tekst = mysql_fetch_assoc(mysql_query($query_tekst));  
$interesse = $txt_tekst["interesse_id"];  
  
IF ($interesse == "1")  
$message = $message1;  
IF ($interesse == "2")  
$message = $message2;  
IF ($interesse == "3")  
$message = "$message1<p>$message2";

Is there someone who built a system like this before? And otherwise, is there someone who can give me some advise on how to make it work?

Many thanks!

Michael
michael

Posts: 6
Posted: 04/21/2004, 12:12 AM

Hello everybody,

Still looking for a solution for this. Can anybody help with any suggestions, because I'm completely stuck!

Thanks!

Michael
View profile  Send private message
Jurn
Posted: 04/21/2004, 7:24 AM

Sorry Michael, but I think the question is difficult to understand and maybe this form is not the good place.

Good luck

Jurn
Langston
Posted: 04/21/2004, 10:07 AM

I think I know what you want to do and I cannot give you a complete answer unless I know your database layout. Here is a general direction. But first, a question:

How do you store multiple interests for a subscriber in the database record? As a text field with interests concatenated or is there a separate subscriber record for each record?

In your example script you prabably want to remove the WHERE clause because to want to process ALL records and not just certain interests.

Then you need a "for" loop to sequentially process the returned record set.

If you need more guidelines you can contact me atceinj@aol.com
michael

Posts: 6
Posted: 04/22/2004, 12:23 AM

Hello,

OK, I allready figured out some more stuff, but it still isn't working they way I want it to work.
Let me explain how the database works.
In this case, it's just about two tables (I'm from Holland, so the table-names may seem a bit weird to you):

- personen
- interesse_persoon

All the main info about the subscribers is stored in the table 'personen'. Every person can choose his fields of interest. There are five different interest, they need to pick at least one, but they can also pick all five of course.
This is stored in the table 'interesse_persoon', just the person_id and the interest_id.

This is the bit of scripting I have so far:

$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 think this is quite in the right direction, but still not really working. I have the idea that there's something wrong with the way the e-mailaddresses are fetched from the database. I have 3 e-mailaddress in my test-database, and when I test this script, only one mail is sent.

Like I explained in my original post on the forum and as you can see in the script: everybody who subscibes for the list always needs to get the text '$message[0]'.
If somebody subscribes for interest 1 and 5, he needs to get '$message[0]', '$message[1]' and '$message[5]'.
I hope I explained it OK and made clear what I want to do. Hopefully you can help me with that!
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.