title: count the number of rows inserted using PHPEXCEL
body: <p>i am trying to insert excel sheet into mysql DB using PHPEXCEL , i am beginner to php PDO , i am using the code below : </p>
  
  <pre><code>&lt;?PHP
      if (isset($_FILES["file"]))
        {
      $info_file_exts = array("csv", "xls", "xlsx");
      $info_upload_exts = end(explode(".", $_FILES["file"]["name"]));
      if ((($_FILES["file"]["type"] == "Excel/csv")
      || ($_FILES["file"]["type"] == "Excel/xls")
      || ($_FILES["file"]["type"] == "Excel/xlsx")
  
      )
  
      &amp;&amp; in_array($info_upload_exts, $info_file_exts))
  
      if ($_FILES["file"]["error"] &gt; 0)
      {
      echo "Return Code: " . $_FILES["file"]["error"] . "&lt;br&gt;";
      }
      else
      {
      $info_file_exts = array("csv", "xls", "xlsx");
      if($info_file_exts[0]=='csv'){
      $ink=explode('.'.$info_file_exts[0],$_FILES["file"]["name"]);
      $time=time();
      $info_new_file_name =$ink[0].'_'.$time.'.'.$info_file_exts[0];
      }
      else if($info_file_exts[1]=='xls')
      {
      $ink=explode('.'.$info_file_exts[1],$_FILES["file"]["name"]);
      $time=time();
      $info_new_file_name =$ink[0].'_'.$time.'.'.$info_file_exts[0];
      }
      else if($info_file_exts[2]=='xlsx')
      {
      $ink=explode('.'.$info_file_exts[2],$_FILES["file"]["name"]);
      $time=time();
      $info_new_file_name =$ink[0].'_'.$time.'.'.$info_file_exts[0];
      }
  
      }
  
      $path = ($_FILES["file"]["tmp_name"]);
      $objPHPExcel = PHPExcel_IOFactory::load($path);
      foreach ($objPHPExcel-&gt;getWorksheetIterator() as $worksheet) 
      {
           $worksheetTitle = $worksheet-&gt;getTitle();
           $highestRow = $worksheet-&gt;getHighestRow(); // e.g. 10
           $highestColumn = $worksheet-&gt;getHighestColumn(); // e.g 'F'
           $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);
      }
      $nrColumns = ord($highestColumn) - 64;
      echo "File ".$worksheetTitle." has ";
      echo $nrColumns . ' columns';
      echo ' y ' . $highestRow . ' rows.';
      echo 'Data: &lt;table width="100%" cellpadding="3" cellspacing="0"&gt;&lt;tr&gt;';
      for ($row = 1; $row &lt;= $highestRow; ++ $row)
       {
         echo '&lt;tr&gt;';
         for ($col = 0; $col &lt; $highestColumnIndex; ++ $col)
          {
             $cell = $worksheet-&gt;getCellByColumnAndRow($col, $row);
             $val = $cell-&gt;getValue();
             if($row === 1)
                  echo '&lt;td style="background:#000; color:#fff;"&gt;' . $val . '&lt;/td&gt;';
             else
                 echo '&lt;td&gt;' . $val . '&lt;/td&gt;';
         }
      echo '&lt;/tr&gt;';
      }
      echo '&lt;/table&gt;';
      for ($row = 2; $row &lt;= $highestRow;  ++$row) 
      {
      $val=array();
      for ($col = 0; $col &lt; $highestColumnIndex; ++ $col)
       {
          $cell = $worksheet-&gt;getCellByColumnAndRow($col, $row);
          $val[] = $cell-&gt;getValue();
  
      }
      $email=$val[0];
      $pass= $val[1];
      $sql="insert into users (email, password) VALUES (:email,:pass)";
      $q = $conn-&gt;prepare($sql);
      $q-&gt;execute(array(':email'=&gt;$email,':pass'=&gt;$pass));
      }
         ?&gt;
  
      &lt;div style="width: 500px; margin: 200px auto 0 auto;"&gt;
      &lt;form action="display.php" method="post" enctype="multipart/form-data" &gt;
      &lt;label for="file"&gt;Filename: &lt;/label&gt;
      &lt;input type="file" name="file" id="file"&gt;&lt;br&gt;
      &lt;input type="submit" name="submit" value="Submit" style="margin-left:90PX"&gt;
      &lt;/form&gt;
  
      &lt;/div&gt;
  </code></pre>
  
  <p>this code works fine , but i want to do is to count how many rows are added? , i  try to use <code>rowCount()</code> function but it return the output for each insert , i want to use it with all the insert task, another thing an  error shows if the user click the submit button more than one time how can i fix that ? </p>