SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard tgavin's Avatar
    Join Date
    Feb 2003
    Location
    FL
    Posts
    1,051
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    textarea \n = new record

    I would like to enter email addresses into an text area, each address seperated by a new line. Then , each address will become it's own record.

    so, if I enter into the text area
    email01@foo.com
    email02@foo.com

    in the db each email address has it's own record
    id = 1, email = email01@foo.com
    id = 2, email = email02@foo.com

    What's the best way to do this?
    Thanks!

  2. #2
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $emails split("\n"$userinput);
    foreach(
    $emails as $email)
    {
     
    // insert

    Would work.
    Mike
    It's not who I am underneath, but what I do that defines me.

  3. #3
    SitePoint Wizard Dean C's Avatar
    Join Date
    Mar 2003
    Location
    England, UK
    Posts
    2,906
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Something like:
    PHP Code:
    $emails preg_split('/[\r\n]+/'$_POST['emails']);
    foreach(
    $emails AS $email)
    {
        
    mysql_query("INSERT INTO table (somefield) VALUES ('" mysql_real_escape_string($email) . "')");


  4. #4
    SitePoint Wizard tgavin's Avatar
    Join Date
    Feb 2003
    Location
    FL
    Posts
    1,051
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys, that was perfect!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •