473,320 Members | 2,117 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Newby question on creating an array

Joe
I want to select a bunch of email addresses from a mysql table and format
them to use with a php mail() function. I can select them from the database,
but how do I format them so there's a comma and space after every one?

Jul 19 '05 #1
2 2694
Joe wrote:
I want to select a bunch of email addresses from a mysql table and format
them to use with a php mail() function. I can select them from the database,
but how do I format them so there's a comma and space after every one?


Don't do that! :)

You're saying you'd like one big-ass To: field? Kinda like To:
yo*@test.com, me@test.com, fr***@test.com?

Use a loop.
$result = mysql_query("SELECT email FROM tblEmail");

while($row = mysql_fetch_array($result)) {
mail($row['email'],$subject,$message,"From:yo*@test.com\r\n");
}

------------------------------------

Even though you shouldn't, here's how to format them the way you asked:
$result = mysql_query("SELECT email FROM tblEmail");

while($row = mysql_fetch_array($result)) {
$to = $to . $row['email'] . ", ";
}

And then just remove the last ", " from the string and call the mail
function once. But that would be icky.
--
Sugapablo
------------------------------------
http://www.sugapablo.com <--music
http://www.sugapablo.net <--personal

Jul 19 '05 #2
Joe wrote:
I want to select a bunch of email addresses from a mysql table and format
them to use with a php mail() function. I can select them from the database,
but how do I format them so there's a comma and space after every one?


Don't do that! :)

You're saying you'd like one big-ass To: field? Kinda like To:
yo*@test.com, me@test.com, fr***@test.com?

Use a loop.
$result = mysql_query("SELECT email FROM tblEmail");

while($row = mysql_fetch_array($result)) {
mail($row['email'],$subject,$message,"From:yo*@test.com\r\n");
}

------------------------------------

Even though you shouldn't, here's how to format them the way you asked:
$result = mysql_query("SELECT email FROM tblEmail");

while($row = mysql_fetch_array($result)) {
$to = $to . $row['email'] . ", ";
}

And then just remove the last ", " from the string and call the mail
function once. But that would be icky.
--
Sugapablo
------------------------------------
http://www.sugapablo.com <--music
http://www.sugapablo.net <--personal

Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Damien | last post by:
I have just built a simple stopwatch application, but when i f5 to get things goings i get this message, An unhandled exception of type 'System.ArithmeticException' occurred in...
2
by: Sonoman | last post by:
Hi all: I am getting a "missing storage class or idetifier" error and I do not understand what it means, therefore and I cannot figure it out. I am just starting a new project and I cannot get...
0
by: marco | last post by:
I'm trying to parse a xml bookmarkpage with php. I found a very useful example script about how you can parse a xml document with php. The scriptworks really smooth. The xml test document (See...
9
by: CeyloR | last post by:
Hello everyone, I just started with the language C and it's very interesting. I bought the book 'The C Programming Language' from Brian W. Kernighan and Dennis M. Ritchie. While reading...
9
by: robbie.carlton | last post by:
Hello! I've programmed in c a bit, but nothing very complicated. I've just come back to it after a long sojourn in the lands of functional programming and am completely stumped on a very simple...
3
by: Bernardo | last post by:
Hi, I had to convert a Win32 EXE project with some forms and classes into a DLL Project. When I instace the new DLL project from a test program I see all forms and classes... There is any way to...
10
by: Fred Nelson | last post by:
Hi: I have programmed in VB.NET for about a year and I'm in the process of learing C#. I'm really stuck on this question - and I know it's a "newby" question: In VB.NET I have several...
12
by: Boni | last post by:
Dear all, How can I add something to the VB arrays after the initialization. dim _points() as System.Drawing.points If it is not possible how can I pass into function, with VB array as an...
3
by: Blue Streak | last post by:
Just some basic questions because none of my reference manuals cover this explicitly: 1) If you want have an argument as an array of integers would this be the correct declaration? ...
7
by: maria | last post by:
Hi all I used to work with VB, and now I am trying C# and can't get it start for example in VB Dim Items() as tItems dim NumberOfitems as long obj.GetAllItems(NumberOfitems, Items()) for i=0...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.