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 />"; } Link to comment https://forums.phpfreaks.com/topic/142493-solved-combine-foreach-values/ 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 />"; } Link to comment https://forums.phpfreaks.com/topic/142493-solved-combine-foreach-values/#findComment-746673 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? Link to comment https://forums.phpfreaks.com/topic/142493-solved-combine-foreach-values/#findComment-746706 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 = '[email protected]'; //Remove this line after testing mail($email,"Confirming Information on File",$msg,"From: [email protected]"); } ?> 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: [email protected]" to the email address it should come from Link to comment https://forums.phpfreaks.com/topic/142493-solved-combine-foreach-values/#findComment-746716 Share on other sites More sharing options...
phpretard Posted January 26, 2009 Author Share Posted January 26, 2009 Thank you...! Link to comment https://forums.phpfreaks.com/topic/142493-solved-combine-foreach-values/#findComment-746726 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.