johnc71 Posted November 8, 2008 Share Posted November 8, 2008 I have a DB with pin numbers. Lets say I want to get first 5 pin numbers where the "active" field is set to "yes" and email them to customer. With the code below I will be sending 5 emails but I want to send 1 email with 5 pins. Can someone point me in right direction ? Thanks! $sql1 = mysql_query("SELECT * FROM pins WHERE active='Yes' limit 5") or die mysql_error()); while($r1 = mysql_fetch_assoc($sql1)) { $pin_id = $r1['pin_id']; $pin_number = $r1['pin_number']; @mail($mail_to, $email_subject, $pin_number,$from); } Link to comment https://forums.phpfreaks.com/topic/131890-sending-multiple-query-results-in-single-email/ Share on other sites More sharing options...
Jeremysr Posted November 8, 2008 Share Posted November 8, 2008 In your while loop, build a string which you will be the body of your e-mail: while($r1 = mysql_fetch_assoc($sql1)) { $pin_id = $r1['pin_id']; $pin_number = $r1['pin_number']; $email_body .= "Pin ID: $pin_id Pin Number: $pin_number"; } @mail($mail_to, $email_subject, $email_body,$from); Something like that. Link to comment https://forums.phpfreaks.com/topic/131890-sending-multiple-query-results-in-single-email/#findComment-685171 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.