This topic is locked

Email If condition ...

6/10/2009 9:42:26 AM
PHPRunner General questions
lewisgr author

Hello,
I am trying to create e-mail if a check box has been checked. Here's what I got:

if ($values["MailBrochure"]=-1)

//********** Send email with old data record ************

global $conn,$strTableName;

$email="support@agridryllc.com";

$from="support@agridryllc.com";

$msg="";

$subject="Mail Brochure to Contact";
// modify the following SQL query to select fields you like to send

$rs = db_query("select * from " . $strTableName ." where ". $where,$conn);
if($data=db_fetch_array($rs))

{

foreach($data as $field=>$value)

$msg.= $field." : ".$value."\r\n";

$ret=runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $msg, 'from'=>$from));

if(!$ret["mailed"])

echo $ret["message"];

}


So I tested this on a simple e-mail and it works but I need to know how do I change this code so I only send the Name & address?
Thanks

J
Jane 6/11/2009

Hi,
please see my changes below:

if ($values["MailBrochure"]==-1)

{

//** Send email with old data record ****

global $conn,$strTableName;

$email="support@agridryllc.com";

$from="support@agridryllc.com";

$msg="";

$subject="Mail Brochure to Contact";
// modify the following SQL query to select fields you like to send

$rs = db_query("select Field1,Field2,Field3 from " . $strTableName ." where ". $where,$conn);
if($data=db_fetch_array($rs))

{

foreach($data as $field=>$value)

$msg.= $field." : ".$value."\r\n";

$ret=runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $msg, 'from'=>$from));

if(!$ret["mailed"])

echo $ret["message"];

}

}