if i do it the way it is shown above, it works and i get the email in my inbox but i want to take it from the table because i have many addresses to send to. now i am getting as many emails but sent only to rwahdan@gmail.com because i spacify only one email. how to get the emails from the table?$sql2= "SELECT * FROM tbl_auth_user WHERE subid =5" or die(mysql_error());
$result2 = mysql_query($sql2) or die('Query failed. ' . mysql_error());
if (mysql_num_rows($result) > 0)
{
if ($theday == "Sunday"){
while($row = mysql_fetch_assoc($result))
{
$to = 'rwahdan@gmail.com';
$subject = 'This is the alert report';
php with mail!
Moderator: General Moderators
php with mail!
i am trying to get the email addresses from my table in mysql but i cant! can someone help?
-
fredericomf
- Forum Newbie
- Posts: 2
- Joined: Tue Mar 24, 2009 6:58 pm
Re: php with mail!
Hi!
We need most details about the table: fields.
Regards,
Frederico Mottinha de Figueiredo (facebook)
We need most details about the table: fields.
Regards,
Frederico Mottinha de Figueiredo (facebook)
Re: php with mail!
You would need to loop through your result and email to all the email addresses for your users.
What the foreach loop will do is loop through your result and then run the email code for each user it finds, this should email to all users in your result 
Hope that helps
Matthew Vass
QA Analyst
mvass@hostmysite.com
http://www.hostmysite.com?utm_source=bb
Code: Select all
$sql2= "SELECT * FROM tbl_auth_user WHERE subid =5" or die(mysql_error());
$result2 = mysql_query($sql2) or die('Query failed. ' . mysql_error());
if (mysql_num_rows($result) > 0)
{
if ($theday == "Sunday"){
while($row = mysql_fetch_assoc($result))
{
foreach($result as $entry)
{
$to = $entry['email'] //or whatever your row name is
$subject = 'This is the alert report';
//any other information that should go to the user (from address ect..)
}
Hope that helps
Matthew Vass
QA Analyst
mvass@hostmysite.com
http://www.hostmysite.com?utm_source=bb