Reply to [NEWBIE] Trying to combine array into one string

Your name:

Reply:


Posted by Dave on 10/04/22 11:08

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/

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация