Jump to content

Need to create simple email formula


bulgin

Recommended Posts

I have:

 

SELECT orders.widget,  customers.contactLastName, customers.email, customers.subject, customers.message_body FROM orders JOIN customers ON orders.widget = customers.widget and orders.email_sent="0"

 

produces

 

456897 Beverly [email protected] Order Ready   Your Order is ready

987456 Stanton [email protected] Order Ready Your Order is ready

786342 Clark [email protected] Order Ready Your Order is ready

 

And I need to figure out how to send each one an email message using customers.email, customers.subject, customers.message_body and once done with that, set orders.email_sent = “1”

 

I'm stumped.  Can someone help?

Link to comment
https://forums.phpfreaks.com/topic/145024-need-to-create-simple-email-formula/
Share on other sites

like this ;-)

 

$mailer = mysql_query("SELECT orders.widget,  customers.contactLastName, customers.email, customers.subject, customers.message_body FROM orders JOIN customers ON orders.widget = customers.widget and orders.email_sent='0'") or die (mysql_error());
while($user = @mysql_fetch_array($mailer)){

// do your stuff
             // Ex: $user[contactLastName]

//then
$update = mysql_query("UPDATE ...") or die (mysql_error());

}

Okay, this is what works for me.  I 'd appreciate anyone looking at it to tell me perhaps how it could be made tighter/more secure.  somehow I feel the last part UPDATE could be made better.  And what about the variables set for the php email send?  could that be improved?

 

thanks.

 

<?php
include 'config.php';
include 'opendb.php';


$mailer = mysql_query("SELECT customer_information.email, customer_inf
ormation.email_subject, customer_information.email_body FROM customer_informatio
n where sent_or_not_sent = '199'") or die (mysql_error());

while($user = @mysql_fetch_array($mailer)){
$to=$user[email];
$subject=$user[email_subject];
$body=$user[email_body];
mail($to,$subject,$body) ; 

mysql_query("UPDATE customer_information set sent_or_not_sent = 1 where sent_or_
not_sent = '199'") or die (mysql_error());

}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.