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 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? Quote Link to comment 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()); } Quote Link to comment 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); Quote Link to comment 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()); } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.