Jump to content

Combining Multiple Query Results Into One Variable


sintax63

Recommended Posts

I have to make a mail form (which is already coded) that will pull peoples names and email address from a database based on certain form parameters. I have the form done and am so close on finishing it up but am stuck on some mail() issues.

 

I have the form set up to use:

mail($sendTo, $theSubject, $theMessage, $headers);

 

Using this format, I know that I can send this email to multiple recipients at once doing the following:

mail('Name1 <[email protected]>, Name2 <[email protected]>', $theSubject, $theMessage, $headers);

 

So I have my mySQL query all set up and it looks like so:

$query="SELECT * FROM operations_forms WHERE department='$initiatedBy'";
$result=mysql_query($query);

while( $row = mysql_fetch_assoc( $result ) ) {

$name			= $row["name"]; 
$email			= $row["email"];

$recip = $name . " <" . $email .">, ";
$sendTo = $recip;

}

 

The problem I am having is that my $sendTo variable only is passing on one record, not a combination of all of them. I am at a loss here on how to spit out all the variables and then combine them into one. I can use the above and produce an echo call that looks correct... but it doesn't function correctly on the back end.

 

Any help?  :shrug:

 

Thanks!

 

 

I found one error after using the above code.

 

Results are as follows:

[email protected] , [email protected] , [email protected]

 

I need the comma that separates the address part of the email, like so:

[email protected], [email protected], [email protected]

 

Any way to do that?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.