nthrusse Posted November 25, 2010 Share Posted November 25, 2010 I have little or no! idea what I am doing.. But I foolishly decided I would try some coding.. What I want is to query two table and then send an email to each record holder in the database. I have pieced together this... But it doesn't give me the results of all my vaiables and it doesn't email all the results. Ideas, directions anything would be helpful.. <?php include "vsadmin/db_conn_open.php"; $allprods=mysql_query("select pID, pName, pPrice, pDropship, dsID, dsName, dsEmail from products, dropshipper where pDropship = dsID"); while ($yarr=mysql_fetch_assoc($allprods)) $aname=$yarr["pID"]; $bname=$yarr["pName"]; $cname=$yarr["dsName"]; $to = "[email protected]"; $subject = ("Your Ebook " . $aname); $body = ("Hello,\n\nHow are you you ". $aname ."?\n\nWhats New With you in the World?" . $aname ) ; $headers = "From: [email protected]\r\n" . "X-Mailer: php"; if (mail($to, $subject, $body, $headers)) { echo("<p>Message sent again!</p>"); } else { echo("<p>Message delivery failed...</p>"); } ?> Link to comment https://forums.phpfreaks.com/topic/219848-emailing-from-table/ Share on other sites More sharing options...
Pikachu2000 Posted November 25, 2010 Share Posted November 25, 2010 That script would send all of the emails to the one address assigned to the $to variable. What do you mean it doesn't give the result of all your variables? Link to comment https://forums.phpfreaks.com/topic/219848-emailing-from-table/#findComment-1139654 Share on other sites More sharing options...
nthrusse Posted November 25, 2010 Author Share Posted November 25, 2010 Thanks for the quick response... yes, I know I need to assign a variable in the $to.. But for testing I didn't want to send it to all the email addy's in the database. The issue is it shows $aname, but not $bname or $cname in my email.. and theretically, if I have 5 records it should send out 5 emails and it doesn't Link to comment https://forums.phpfreaks.com/topic/219848-emailing-from-table/#findComment-1139658 Share on other sites More sharing options...
nthrusse Posted November 25, 2010 Author Share Posted November 25, 2010 Silly me, it works once I added a couple {} around the while variable... Link to comment https://forums.phpfreaks.com/topic/219848-emailing-from-table/#findComment-1139689 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.