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 Beverly@yahoo.com Order Ready   Your Order is ready

987456 Stanton Stanton@yahoo.com Order Ready Your Order is ready

786342 Clark Clark@hotmail.com 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
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());

}

Link to comment
Share on other sites

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());

}

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.