1 回答
TA贡献1801条经验 获得超8个赞
// prepare the insert query once outside the loop
$sql = 'INSERT INTO employees (`numbers`, `tids`, `date`, `time`,
`zero`, `terminal_sn`, `space`)
VALUES(?,?,?,?,?,?,?)';
$stmt = $dbcon->prepare($sql);
if (($handle = fopen($_FILES['csv-file']['name'], "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, " ")) !== FALSE) {
// space delimiter ^
// bind the columns to the query parameters
$stmt->bind_param('sssssss', $row[0], $row[1], $row[2], $row[3],
$row[4],$row[5], row[6]);
// execute the query with parameters replaced with data
$stmt->execute();
}
fclose($handle);
}
- 1 回答
- 0 关注
- 105 浏览
添加回答
举报