title: set conditions while uploading from csv file
body: <p>so, I have this users list which I get it from a csv file.</p>
  
  <p>What I need to do is this:
  I get the file to upload, I check for each line if the user exists, if he does then all I do is update him, if he doesn't I should create a new account for him.</p>
  
  <p>I do know how to do it as a logic... but I become confused while using the csv import...</p>
  
  <p>So, here it is what I use:</p>
  
  <pre><code>$handle = fopen($_FILES['filename']['tmp_name'], "r");
  
  while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
      $import="INSERT into users (Username,Password,Email,first_name,last_name,phone,user_id,age,sex) values('$data[0]','".md5($data[1])."','$data[2]','$data[3]','$data[4]','$data[5]','$data[6]','$data[7]','$data[8]')";
      mysql_query($import) or die(mysql_error());
  }
  
  fclose($handle);
  </code></pre>
  
  <p>What I need is something like this:</p>
  
  <pre><code>foreach (user as $data[7]) {
      if user exists in user table then $query1 
      else $query2    
  }
  </code></pre>
  
  <p>Thanks</p>