내 페이지 매김이 다른 기능에서 작동하지 않는 이유는 무엇입니까? 페이지 매김 링크가 표시되지만 첫 페이지는 모든 데이터를 표시하지만 페이지의 다른 링크는 데이터를 표시하지 않습니다.
public function index(){
$this->load->library('pagination');
$page = $this->uri->segment(2);
$param = new stdClass();
if (!isset($page) || $page == '') {
$page = 1;
}
$param->per_page = 5;
$param->limit = ($page - 1) * $param->per_page;
$paginate_url = site_url('warehouse');
$data['total_result'] = $this->m_stock->count ($param);
$config['uri_segment'] = 2;
$config['num_links'] = 3;
$config['base_url'] = $paginate_url;
$config['total_rows'] = $data['total_result'];
$config['per_page'] = $param->per_page;
$config['use_page_numbers'] = TRUE;
$config['page_query_string'] = FALSE;
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$data['item'] = $this->m_stock->get_item_code($param);
$this->load->view('v_all_stocks', $data);
}
이 함수 카운트 데이터베이스
function count(){
$this->db->select("*");
$this->db->from("tbl_item_code");
$this->db->where('active', '1');
$num_results = $this->db->count_all_results();
return $num_results;
}
이 시도 :
public function index(){
$this->load->library('pagination');
$page = $this->uri->segment(2);
$param = new stdClass();
if (!isset($page) || $page == '') {
$page = 1;
}
$param->per_page = 5;
$param->limit = ($page - 1) * $param->per_page;
$paginate_url = site_url('warehouse');
$results = $this->m_stock->get_item_code($param); //get the db query object here
$data['total_result'] = $results->num_rows(); //get the number of results for this query
$config['uri_segment'] = 2;
$config['use_page_numbers'] = TRUE; //add this line if you wnat to use page numbers instead of offset in url
$config['num_links'] = 3;
$config['base_url'] = $paginate_url;
$config['total_rows'] = $data['total_result'];
$config['per_page'] = $param->per_page;
$config['use_page_numbers'] = TRUE;
$config['page_query_string'] = FALSE;
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$data['item'] = $results->result(); //get the results
$this->load->view('v_all_stocks', $data);
}
모델 코드에서 :
function get_item_code($param){
$result = array();
$sql = "select ic.id, ic.item_code, ic.description, maxdt.maxdt, lc.balance ";
$sql .= "from tbl_item_code ic ";
$sql .= "left join ( tbl_lines_code lc inner join ( select id, max(dt) maxdt from tbl_lines_code group by id ) maxdt ";
$sql .= "on lc.id = maxdt.id and lc.dt = maxdt.maxdt ) on ic.id = lc.id ";
$sql .= "where ic.active = 1";
if ($param->limit > 0)
$this->db->limit($param->per_page, $param->limit);
else
$this->db->limit($param->per_page);
return $this->db->query($sql); //change it to return the db query object
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다