我正在尝试插入多个复选框。
当我插入2个或更多复选框时,它仅显示我输入的最后一个复选框。我选中的另一个复选框未在sql表中输入。
我的模型
public function addBatch($data, $feetype_id) {
$this->db->trans_begin();
if (isset($data['id'])) {
$this->db->where('id', $data['id']);
$this->db->update('fee_session_groups', $data);
$fee_session_group_id = $data['id'];
} else {
$this->db->insert('fee_session_groups', $data);
$fee_session_group_id = $this->db->insert_id();
}
$feeGrouptype_array = array();
foreach ($feetype_id as $month) {
$session_id = $this->setting_model->getCurrentSession();
$amount = $this->input->post('amount');
$penalty = $this->input->post('penalty');
$fee_groups_id = $this->input->post('fee_groups_id');
// $start_date = $this->input->post('start_date');
// $end_date = $this->input->post('end_date');
$vehicle_array[] = array(
'fee_session_group_id' => $fee_session_group_id,
'feetype_id' => $month,
'fee_groups_id' => $fee_groups_id,
'session_id' => $session_id,
// 'start_date' => $start_date,
// 'end_date' => $end_date,
'amount' => $amount,
'penalty' => $penalty,
);
}
$this->db->insert_batch('fee_groups_feetype', $vehicle_array);
$ids[]=$this->db->insert_id();
if ($this->db->trans_status() === FALSE) {
$this->db->trans_rollback();
} else {
$this->db->trans_commit();
}
}