#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    145
    Rep Power
    15
    I want to que email addresses out of mySQL into an array so I can email the same message to everybody on my email list. Is this possible - is there a better way?

    Thanks
  2. #2
  3. No Profile Picture
    Robert_J_Sherman
    Guest
    Devshed Newbie (0 - 499 posts)
    of course, simple build your array via like a while statement...

    for example:
    $sql = "SELECT myemail FROM email";

    $result = mysql_query($sql);

    while ($myrow = mysql_fetch_array($result)) {
    $myemail[] = $myrow[0];
    }

    there, you have your array, in $myemail.

    to pull em' out use you for loop, like:
    for($i=0; $i<count($myemail); $i++) {
    echo "$myemail[$i]n";
    }

    the above is not intended to fully operate, some added work would most definately be required.

    I do hope it helps.

    ------------------
    SnR Graphics,
    Low Cost Hosting and Web Development.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    45
    Rep Power
    15
    As a little addition to what Robert Sherman wrote, here's a code that will actually email your message to everyone..

    $sql = "SELECT myemail FROM email";

    $result = mysql_query($sql);
    $to="";

    while ($myrow = mysql_fetch_array($result))
    {
    $to.=($myrow["myemail"].";");
    }

    $subject="Your subject";
    $message="Your message";

    mail("$to","$subject","$message");

    That should mail everyone your message. Only part I'm not sure of is what you need to add in between recipients email address to seperate them. Pretty sure it's a semi-colon but you might want to check up on that.
    mail(

  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2000
    Posts
    669
    Rep Power
    15
    Polman was right on track but it's a "," not a ";" to seperate email addresses
  8. #5
  9. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15

    but it's a "," not a ";" to seperate email addresses


    The email seperater can be a space also.
    (ie, both "," and " " will work)..


    ------------------
    SR -
    webshiju.com

    "The fear of the LORD is the beginning of knowledge..."

Similar Threads

  1. sending email + multiple attachments using php
    By gbow in forum PHP Development
    Replies: 6
    Last Post: February 13th, 2004, 09:31 AM
  2. sort: find duplicate string elements in array
    By sciencelife in forum Java Help
    Replies: 3
    Last Post: January 27th, 2004, 01:29 PM
  3. C++ programming help.
    By Programming1 in forum C Programming
    Replies: 1
    Last Post: January 20th, 2004, 10:47 AM
  4. Array manipulation and removal of array values
    By timwi in forum Perl Programming
    Replies: 10
    Last Post: January 14th, 2004, 10:49 AM
  5. splitting an array by matching values
    By urge in forum PHP Development
    Replies: 0
    Last Post: December 19th, 2003, 01:06 AM

IMN logo majestic logo threadwatch logo seochat tools logo