phpretard Posted January 26, 2009 Share Posted January 26, 2009 Each row in my DB contains -- email | phone | bill_to --- I would like to send an email to each person with the information specific to them. The code below does display the information but I don't believe it associates them. So each email would read: ------------------------------------------- Dear Person I am emailing, Here is the information we have on file: Email Address: email[at]email.com Bill-To Number: 123456 Phone Number: 123-456-7890 I hope you got this, Anthony ps. if you did get this thank you phpfreaks. ------------------------------------------- while($row = mysql_fetch_array($result)) { $email[]=$row['email']; $billto[]=$row['bill_to']; $phone[]=$row['phone']; } foreach($email as $mailto){ echo "$mailto<br />"; } foreach($billto as $billnumber){ echo "$billnumber<br />"; } foreach($phone as $telephone){ echo "$telephone<br />"; } Quote Link to comment Share on other sites More sharing options...
rhodesa Posted January 26, 2009 Share Posted January 26, 2009 while($row = mysql_fetch_array($result)) { $email=$row['email']; $billto=$row['bill_to']; $phone=$row['phone']; echo "$email<br />"; echo "$billto<br />"; echo "$phone<br />"; echo "<hr />"; } Quote Link to comment Share on other sites More sharing options...
phpretard Posted January 26, 2009 Author Share Posted January 26, 2009 Thank you for the response. I understand wht you did there. what I need is the results of what you did to go through the databse and send an email for each query match. while($row = mysql_fetch_array($result)) { $email=$row['email']; $billto=$row['bill_to']; $phone=$row['phone']; echo "$email<br />"; echo "$billto<br />"; echo "$phone<br />"; echo "<hr />"; } foreach (($email $billto $phone) as $mailto){ email script } } Am I making any sense? Quote Link to comment Share on other sites More sharing options...
rhodesa Posted January 26, 2009 Share Posted January 26, 2009 put the email script inside the WHILE...don't do a separate loop... <?php while($row = mysql_fetch_array($result)) { $email=$row['email']; $billto=$row['bill_to']; $phone=$row['phone']; $msg = "Dear $email, Here is the information we have on file: Email Address: $email Bill-To Number: $billto Phone Number: $phone I hope you got this, Anthony"; $email = 'test@email.com'; //Remove this line after testing mail($email,"Confirming Information on File",$msg,"From: you@email.com"); } ?> just before the mail is sent, i added a line to override where the email is being sent to. you may want to use your email address here for testing, then remove the line when you want to actually use it. also, update the value in "From: you@email.com" to the email address it should come from Quote Link to comment Share on other sites More sharing options...
phpretard Posted January 26, 2009 Author Share Posted January 26, 2009 Thank you...! 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.