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 = "author@email.com"; $subject = ("Your Ebook " . $aname); $body = ("Hello,\n\nHow are you you ". $aname ."?\n\nWhats New With you in the World?" . $aname ) ; $headers = "From: me@me.com\r\n" . "X-Mailer: php"; if (mail($to, $subject, $body, $headers)) { echo("<p>Message sent again!</p>"); } else { echo("<p>Message delivery failed...</p>"); } ?> Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment 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... 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.