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[0]) {
mysql_query("INSERT INTO PowerFlex (customerCode, postCode,Name, Address1,Address2) VALUES
(
'".addslashes($data[0])."',
'".addslashes($data[1])."',
'".addslashes($data[2])."',
'".addslashes($data[3])."',
'".addslashes($data[4])."',
'".addslashes($data[5])."',
etc
)
");
}
} while ($data = fgetcsv($handle,1000,",",'"'));
//
}
此代码将我的 CSV 上传到数据库中,但不会跳过 CSV 第一行中的标题(字段),也不会根据我的数据库表的标题检查标题。我怎么做 ?