-1
我從db中列出註冊員工,每頁顯示10名員工。我正在使用codeignator分頁。Codeignator-分頁顯示刪除/編輯後的空數據
如果我刪除了2頁的員工,刪除後,我需要去2顯示了員工的休息頁第2頁
查看:
<a href="<?php echo $path;?>welcome/delete_employee/employeeid/<?php echo $row->empID;?>/pageNum/<?php echo $currentPage; ?>" onClick="return delAlert()";><img src="<?php echo $path;?>/img/delete.png" height="30px" width="30px" /></a>
控制器:
public function delete_employee()
{
$session_id = $this->session->userdata('logged_in');
if($session_id) {
$array = $this->uri->uri_to_assoc(3);
$count=$array['pageNum']-1;
$i=$count*10;
$this->load->model('welcomemodel','m',true);
$this->m->deleteemployee($array['employeeid']);
$config = array();
$config["base_url"] = base_url() . "welcome/employee";
$config["total_rows"] =$this->m->employee_count();
$config["per_page"] = 10;
$config["uri_segment"] = $array['pageNum'];
$data['showData'] = $this->m->getEmployee($config["per_page"], $i);
$this->pagination->initialize($config);
$data["links"] = $this->pagination->create_links();
$data["currentPage"] =$array['pageNum'];
$this->load->view('header');
$this->load->view('employee',$data);
} else {
$this->load->view('session_expired');
}
}
型號:
public function deleteemployee($employeeid)
{
$this->db->where('empID',$employeeid);
$this->db->delete('employee');
return $this->db->affected_rows();
}
public function getEmployee($limit, $start)
{
$this->db->limit($limit, $start);
$this->db->select()
->from('employee')
->order_by('emp_fname');
$this->db->join('service', 'employee.serviceID = service.serviceID','left');
$query=$this->db->get();
return $query;
}
public function employee_count()
{
return $this->db->count_all("employee");
}
但現在的分頁鏈接顯示第一頁的鏈接,即使顯示的第二頁的內容....
'$ page =($ this-> uri-> segment(3))? $ this-> uri-> segment(3):0;'是錯誤的。第三部分是您的員工編號,而不是您的頁碼。 – AdrienXL
@ AdrienXL 我編輯了我的代碼和內容正在顯示,但顯示不正確的分頁鏈接。即使刪除後顯示的第二頁的內容顯示第一頁的鏈接鏈接:( –