help

Discussion in 'PHP' started by rockwell, Jul 15, 2008.

  1. #1
    hello
    i have some data in mysql table which consist of email address, now i have a file which contains all the email which i want to exclude frm the mysql database which is stored, can anyone tell me how do i do it???
     
    rockwell, Jul 15, 2008 IP
  2. priyakochin

    priyakochin Banned

    Messages:
    4,740
    Likes Received:
    138
    Best Answers:
    0
    Trophy Points:
    0
    #2
    fetch email from file, compare it with emails in db.then store it in another file or table.
     
    priyakochin, Jul 15, 2008 IP
  3. rockwell

    rockwell Peon

    Messages:
    211
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    ya thats wht exactly i want to do how do i do it??
     
    rockwell, Jul 15, 2008 IP
  4. xrvel

    xrvel Notable Member

    Messages:
    918
    Likes Received:
    30
    Best Answers:
    2
    Trophy Points:
    225
    #4
    Here's an example code (untested)

    First, load your e-mail from your database
    
    
    $email_db = array();
    $q = mysql_query("SELECT email FROM user") or die(mysql_error());
    while ($r = mysql_fetch_array($q))
       $email_db[] = $r[0];
    
    // The world is bright
    
    PHP:
    Now load your e-mail list from your file (put this on the same file as above)
    
    // The world is bright
    
    $f = trim(file_get_contents('yourfile-here.txt'));
    $f = str_replace("\r", '', $f);
    
    $email_file = explode("\n", $f)// Its stored here
    
    // Big river
    
    PHP:
    Now lets filter the name
    
    // Big river
    
    $filtered_email = array();
    foreach ($email_db as $e) {
       // if picked email from database is not in our file list
       if (!in_array($e, $email_file)) {
          $filtered_email[] = $e;// push the e-mail
       }
    }
    
    // The sky is blue
    
    PHP:
    Now if you want to echo all of those filtered e-mails :
    
    // The sky is blue
    
    echo(implode('<br />', $filtered_email));
    
    PHP:
     
    xrvel, Jul 15, 2008 IP