Email Adding Program.. **** Can You Help Me Regarding ****

Discussion in 'PHP' started by strgraphics, Jan 22, 2010.

  1. #1
    i am need to create one email adding program., so i am using the code..

    
    
    $sql="INSERT INTO $tbl_name(email)VALUES('$email')";
    $result=mysql_query($sql);
    
    
    PHP:
    But this adding successfully but only one email id at a time but i need add more than one separated with commas...,

    Example: , ,.............

    Any body help me regarding this...!
     
    strgraphics, Jan 22, 2010 IP
  2. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #2
    JAY6390, Jan 22, 2010 IP
  3. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #3
    $email_addresses = "abcd@testing.com, efgh@testing.com, ijkl@testing.com";
    $sql = "insert into $tbl_name (email) values('"
       . join("'), ('", preg_split('/\s*,\s*/', $email_addresses))
       . "')";
    $result = mysql_query($sql);
    PHP:
    Untested but should work.
     
    SmallPotatoes, Jan 22, 2010 IP
  4. strgraphics

    strgraphics Active Member

    Messages:
    710
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #4
    hello JAY6390, your vision is correct but, i am posting those emails, i mean once i add the email on del.php, and i press the button delete then that email is post to delmail.php then

    the program is:

    $sql="INSERT INTO $tbl_name(email)VALUES('$email')";
    $result=mysql_query($sql);

    When i add emails with commas in del.php, then ???
     
    strgraphics, Jan 22, 2010 IP
  5. strgraphics

    strgraphics Active Member

    Messages:
    710
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #5
    hello SmallPotatoes,

    thanks a lot yours is working.... 100% ;)

    Any way thanks SmallPotatoes & JAY6390. i got finally
     
    strgraphics, Jan 22, 2010 IP
  6. strgraphics

    strgraphics Active Member

    Messages:
    710
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #6
    i am successfully adding multiple emails though your code:

    
    $email_addresses = "abcd@testing.com, efgh@testing.com, ijkl@testing.com";
    $sql = "insert into $tbl_name (email) values('"
       . join("'), ('", preg_split('/\s*,\s*/', $email_addresses))
       . "')";
    $result = mysql_query($sql);
    
    PHP:
    Same time can you help me regarding the deleting too.
     
    strgraphics, Jan 22, 2010 IP