Count inserted csv records with PHP

0

Before explaining my problem I want to emphasize that I already look at the possible answers to my question, and they all deal with something different. What I want to do is that when I import a CSV file into a table, it shows me the number of rows that I have inserted or that the file has, or if a file that shows a message that I have selected is not selected, the file It goes well, but the problem is that it does not show me the count of the rows, until now I have the following code:

<?php        
if(isset($_POST['importar'])){        
echo "<center>";
echo "<img src='../IMAGENES/candado.png'>";     
echo "</center>";
}
?>
<?php
extract($_POST);
if($action == "upload"){
$archivo = $_FILES['file']['tmp_name'];
$row = 1; 
$fp = fopen ($archivo,"r"); 
while ($data = fgetcsv ($fp, 1000, ";")){ 
  $num = count ($data); 
  print " <br>"; 
  $row++; 
  $insertar="INSERT INTO acta_entrega_huawei (NUMERO, PLANILLA, N_PEDIDO, 
  PROCESO, FECHA_E_FAC, FECHA_E_CON, FECHA_OPE, OBSERVACIONES) VALUES 
  ('$data[0]', '$data[1]', '$data[2]', '$data[3]', '$data[4]', '$data[5]', 
  '$data[6]', '$data[7]');

mysql_query($insertar);
} 
fclose ($fp); 

echo "<td><center><font face=\"arial\" color=\"green\"><b>Registros 
insertados ".$row."</b></font></center></td>";
}
?>
    
asked by Anderviver 30.06.2017 в 17:30
source

0 answers