This topic is locked

send filtered e-mails from another table

10/4/2007 6:52:27 PM
PHPRunner General questions
S
sales author

Hi,
I need to send mails using another table field where address is stored.
I have 2 table - associats and clients and i want to send e-mail to a certain client who have a field equal with another from associats.
I have the following fields in each table:
associats
name
profile
address
phone
clients
name
description
phone
zip
When i enter data in first table i want to send mail to all clients who have field description equal with field profile and viceversa (when i enter data in clients table i want to send mail to all associates who have field profile equal with description).
Please give me some sollutions.
Thank you in advance!

J
Jane 10/8/2007

Hi,
you can do it using Before record added event on the Events tab.

Here is a sample code for the clients table:

global $conn;

$strSelect = "select address from associats where profile='".$values["description"]."'";

$rs = db_query($strSelect,$conn);

while ($data = db_fetch_array($rs))

{

$email=$data["address"];

$message="";

$subject="New data record";
foreach($values as $field=>$value)

$message.= $field." : ".$value."\r\n";
mail($email, $subject, $message);

}

L
luck 10/11/2007

Thank you! This sollution is working for me too!

S
sales author 10/11/2007

Hi Jane,
Thank you for you prompt sollution. Is working but now i have another problem. I had to add a new table for another set of informations and i need to send the same kind of mail but with address from the first table. This is my new tables:
associats
name
profile
address
phone
clients

name
description
phone
zip
details
type
special info
details
observations
and i need to send mail with email address from associats and only if field 'type' from table 'details' is equal with field 'description' from clients.
I try to add a new field 'email' in 'details' table and i add an event before record added in witch i try to insert email adress from 'associats' in the field email from table 'details' but is creating a new set of records and in the current record the field mail is steel null. Please tell me how to insert emails from address field belongs to the first table in email field witch i called 'email' in the 'details' table. Or if it is another sollution please tell me how to do to send this mail.
Thank you in advance!

Alexey admin 10/11/2007

Hi,
this is just a sample code.

You need to adapt it to meet your needs.

If you experience difficulties with this contact support team directly at support@xlinesoft.com