title: Count lines in csv-file after submitting in form
body: <p>How could i capture the "nicefile.csv" and count the rows in the file after i submit it with POST from a form? I tried something like <code>$csvlinecount = count(file('$_FILES[csv]'));</code> without result. The reason is i have code that counts amout of rows in my database before and after i import the csv-values, but im sorting out duplicate entries. So it would be fun to know if the before number of entries is 100 and after it´s 200, then i know it imported 100 new lines. But if i dont know the amount of lines in the csv-file, i dont know how many it skipped during the import. </p>
  
  <pre><code>&lt;?php 
  
  if ($_FILES[csv][size] &gt; 0) {
  
  //get the csv file
  $file = $_FILES[csv][tmp_name];
  $handle = fopen($file,"r");
  
  //loop through the csv file and insert into database
  do {
  if ($data[0]) {
      mysql_query("INSERT IGNORE INTO wifi (bssid, channel, privacy, ciper, auth, power, essid, latitude, longitude, first_seen, last_seen) VALUES
          (
              '".addslashes($data[0])."',
              '".addslashes($data[1])."',
              '".addslashes($data[2])."',
              '".addslashes($data[3])."',
              '".addslashes($data[4])."',
              '".addslashes($data[5])."',
              '".addslashes($data[6])."',
              '".addslashes($data[7])."',
              '".addslashes($data[8])."',
              '".addslashes($data[9])."',
              '".addslashes($data[10])."' 
          )
      ");
  }
  } while ($data = fgetcsv($handle,1000,","));
  
  //redirect
  header('Location: index.php/upload?success=1'); die;
  
  }
  
  //Count after import
  $after = mysql_query("SELECT * FROM wifi");
  $num_rows_after = mysql_num_rows($after);
  
  
  //echo stats
  echo "Number of rows before - ";
  echo "$num_rows_before";
  &lt;br&gt;
  echo "Number of rows after - ";
  echo "$num_rows_after";
  
  //generic success notice
  if (!empty($_GET[success])) { echo "&lt;br&gt;&lt;b&gt;Result: Your file is imported!&lt;/b&gt;&lt;br&gt;"; } 
  
  //Close connection to databse
  mysql_close($connect) ; 
  
  ?&gt;
  </code></pre>