Emailing Multiple Query results
Posted: Fri Nov 07, 2008 7:33 pm
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!
Code: Select all
$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);
}