|
Posted by Gareth Williams on 10/04/83 11:08
Use implode:
http://nl2.php.net/manual/en/function.implode.php
On 15 Feb 2005, at 16:37, Dave wrote:
> PHP General,
>
> The Situation:
> I'm retrieving some email addresses from a database. I want to be
> able assemble all the addresses into one string that I can use in the
> mail() command. At no time should there ever be more than about 5
> email addresses collected from the database. I want all addresses to
> appear in the "To:" field so everyone receiving the email will know
> who else has a copy.
>
> The Problem:
> I can't quite figure out how to take the results of the
> mysql_query() and assemble them into a string. In my experiments so
> far, I either get a "mysql_data_seek(): Offset 0 is invalid for MySQL
> result index" error, or my mail function sends to a blank address.
>
> What I've Tried So Far:
> My own code is obviously flawed in syntax in logic, so I searched
> the manual and this list's archives under the terms "array",
> "concatenate", "convert", "append" and "string" in various
> combinations. However, while I learned some interesting tips on a
> variety of topics, I suspect I'm missing some essential description
> that will lead me to the command I need.
>
> The Question:
> How do I take the contents of an array and turn them into a single
> string?
>
> For Reference:
> Here is the code I have. I know it's flawed, but hopefully it will
> give an indication of what I'm trying to achieve:
> --code--
> $tantoQuery = "SELECT forum_members.emailAddress AS email FROM
> forum_members, event_tanto WHERE forum_members.ID_MEMBER =
> event_tanto.tanto AND event_tanto.event ='" . $show . "'";
>
> $tantoResult = mysql_query($tantoQuery);
>
> while ($tantoData = mysql_fetch_array($tantoResult))
> {
> $tantoEmail = $tantoEmail . "," . $tantoData;
> }
>
> mail($tantoEmail, $subject, $mailcontent, $addHeaders);
> --code--
>
> Any help would be much appreciated.
>
> --
> Dave Gutteridge
> dave@tokyocomedy.com
> Tokyo Comedy Store
> http://www.tokyocomedy.com/english/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
Navigation:
[Reply to this message]
|