while ($tantoData = mysql_fetch_array($tantoResult)) { $tantoEmailArray[] = $tantoData; } now all the values are stored into an array ($tantoEmailArray). to convert an array to a string and join the elements together by a delimiter, use "implode". hence: implode(",",$tantoEmailArray); so final email command could be: mail(implode(",",$tantoEmailArray), $subject, $mailcontent, $addHeaders); cheers "Dave" <dave@xxxxxxxxxxxxxxx> wrote in message news:4212171E.5000900@xxxxxxxxxxxxxxxxxx > 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@xxxxxxxxxxxxxxx > 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