bulgin Posted February 13, 2009 Share Posted February 13, 2009 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 More sharing options...
drisate Posted February 13, 2009 Share Posted February 13, 2009 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 https://forums.phpfreaks.com/topic/145024-need-to-create-simple-email-formula/#findComment-760988 Share on other sites More sharing options...
bulgin Posted February 13, 2009 Author Share Posted February 13, 2009 Thanks drisate -- I think you are pointing me in the right direction. would I then? mail( $customers.email, $customers.subject, $customers.message_body); Link to comment https://forums.phpfreaks.com/topic/145024-need-to-create-simple-email-formula/#findComment-760991 Share on other sites More sharing options...
bulgin Posted February 13, 2009 Author Share Posted February 13, 2009 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 https://forums.phpfreaks.com/topic/145024-need-to-create-simple-email-formula/#findComment-761400 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.