我想尝试使用 php 和 mysql 导入 .csv 文件,但它显示错误。看我的代码:
function import()
{
$this->load->library('csvimport');
$file_data = $this->csvimport->get_array($_FILES["csv_file"]["tmp_name"]);
//echo $file_data;
foreach ($file_data as $row){
//error_reporting(0);
if($row["Check-in at"] > '0:00:00'){
$date = date('Y-m-d',strtotime($row["Date"]));
$duplicate = $this->attendance_model->getDuplicateVal($row["Employee No"],$date);
//print_r($duplicate);
if(!empty($duplicate)){
$data = array();
$data = array(
'signin_time' => $row["Check-in at"],
'signout_time' => $row["Check-out at"],
'working_hour' => $row["Work Duration"],
'absence' => $row["Absence Duration"],
'overtime' => $row["Overtime Duration"],
'status' => 'A',
'place' => 'office'
);
$this->attendance_model->bulk_Update($row["Employee No"],$date,$data);
} else {
$data = array();
$data = array(
'emp_id' => $row["Employee No"],
'atten_date' => date('Y-m-d',strtotime($row["Date"])),
'signin_time' => $row["Check-in at"],
'signout_time' => $row["Check-out at"],
'working_hour' => $row["Work Duration"],
'absence' => $row["Absence Duration"],
'overtime' => $row["Overtime Duration"],
'status' => 'A',
'place' => 'office'
);
//echo count($data);
$this->attendance_model->Add_AttendanceData($data);
}
} else {
}
}
echo "successfully Updated";
}
}
错误是:
遇到 PHP 错误,严重性:通知消息:未定义索引:签入文件名:controllers/Attendence.php 行号:241
回溯:文件:...../../../attendance.php 行:241 函数:error_handler