I'm using SimpleXLSX to import excel files into my database, but I do not want the first line to be added, try using the continue but what it does is insert all the data in the table twice
Here is the code
if (isset($_FILES['file'])) {
require_once __DIR__ . '/simplexlsx.class.php';
if ( $xlsx = SimpleXLSX::parse( $_FILES['file']['tmp_name'] ) ) {
$stmt = $conn->prepare( "INSERT INTO paises (item, codigo_sap, descripcion, und, menor_precio, peso, volumen, provmenor, paisprov, nproceso, emprescon, econtra, fecha) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
$stmt->bindParam( 1, $item);
$stmt->bindParam( 2, $codsap);
$stmt->bindParam( 3, $desc);
$stmt->bindParam( 4, $und);
$stmt->bindParam( 5, $menor);
$stmt->bindParam( 6, $peso);
$stmt->bindParam( 7, $volumen);
$stmt->bindParam( 8, $provme);
$stmt->bindParam( 9, $provpis);
$stmt->bindParam( 10, $proceso);
$stmt->bindParam( 11, $econcur);
$stmt->bindParam( 12, $econtr);
$stmt->bindParam( 13, $fecha);
foreach ( $xlsx->rows() as $fields ) {
if($fields== 1){ $fields++; continue; }
$item = $fields[0];
$codsap = $fields[1];
$desc = $fields[2];
$und = $fields[3];
$menor = $fields[4];
$peso = $fields[5];
$volumen = $fields[6];
$provme = $fields[7];
$provpis = $fields[8];
$proceso = $fields[9];
$econcur = $fields[10];
$econtr = $fields[11];
$fecha = $fields[12];
$stmt->execute();
}
} else {
echo SimpleXLSX::parse_error();
}