如何忽略第一行并在文本区域中回显 csv 文件中的数据并显示成功的记录数。
if ($_FILES[csv][size] > 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[1]) {
mysql_query("INSERT INTO contacts (contact_first, contact_last, contact_mobile, contact_email) VALUES
(
'".addslashes($data[0])."',
'".addslashes($data[1])."',
'".addslashes($data[2])."',
'".addslashes($data[3])."'
)
");
}
} while ($data = fgetcsv($handle,1000,"","'"));
//
//redirect
header('Location: batch_import.php?success=1'); die;
}