Sir try to import my csv file but it added 1 line only.
find the below edited code:
//<?php
$con = mysqli_connect("localhost", "root", "", "couponskamaharaja") or die(mysql_error());
$filePath = "C:/Users/Mukund/Downloads/coupon.csv";
$tableName = "ads";
$fieldDelimiter = ",";
$lineDelimiter = "\n";
// If your csv file has not a header row, remove the line "IGNORE 1 LINES".
mysqli_query($con, '
LOAD DATA LOCAL INFILE "'.$filePath.'"
INTO TABLE '.$tableName.'
FIELDS TERMINATED by '' . $fieldDelimiter . '' ENCLOSED BY '"'
LINES TERMINATED BY '' . $lineDelimiter . ''
IGNORE 1 LINES
') or die(mysql_error());
$query = mysqli_query($con, "SELECT COUNT(*) AS total_rows FROM " . $tableName);
$result = mysqli_fetch_array($query);
$total_rows = $result['total_rows'];
echo $total_rows . " rows have been added to the table " . $tableName;
//?>
Sir try to import my csv file but it added 1 line only.
find the below edited code:
//<?php
$con = mysqli_connect("localhost", "root", "", "couponskamaharaja") or die(mysql_error());
$filePath = "C:/Users/Mukund/Downloads/coupon.csv";
$tableName = "ads";
$fieldDelimiter = ",";
$lineDelimiter = "\n";
// If your csv file has not a header row, remove the line "IGNORE 1 LINES".
mysqli_query($con, '
LOAD DATA LOCAL INFILE "'.$filePath.'"
INTO TABLE '.$tableName.'
FIELDS TERMINATED by '' . $fieldDelimiter . '' ENCLOSED BY '"'
LINES TERMINATED BY '' . $lineDelimiter . ''
IGNORE 1 LINES
') or die(mysql_error());
$query = mysqli_query($con, "SELECT COUNT(*) AS total_rows FROM " . $tableName);
$result = mysqli_fetch_array($query);
$total_rows = $result['total_rows'];
echo $total_rows . " rows have been added to the table " . $tableName;
//?>