Jump to content

CI pagination current page not changing


Yohanne

Recommended Posts

Hi Coders,

i just wanna know on how to set-up pagination while enable_query_strings is enable or set to true. i tried in many ways but im failed.  and i just get the link work but the data cannot retrieved for the next page.

$config["base_url"] = base_url() . "index.php?dir-move=public&switch=branch_reports&task=branch_report_por";
$config["total_rows"] = $this->model_ho_por->page_count_for_br_por_sr_report();
$config["per_page"] = 3;
$config["uri_segment"] = 3;
$config['num_links'] = 2;
$config['page_query_string'] = true;
$config['full_tag_open'] = '<ul class="pagination">';
$config['full_tag_close'] = '</ul>';
config['prev_link'] = '<';
$config['prev_tag_open'] = '<li>';
$config['prev_tag_close'] = '';
$config['first_link'] = 'First';
$config['first_tag_open'] = '<li>';
$config['first_tag_close'] = '';
$config['next_link'] = '>';
$config['next_tag_open'] = '<li>';
$config['next_tag_close'] = '';
$config['cur_tag_open'] = '<li class="active"><a href="">';
$config['cur_tag_close'] = '</a></li>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '';
$config['last_link'] = 'Last';
$config['last_tag_open'] = '<li>';
$config['last_tag_close'] = '';
$this->pagination->initialize($config);
$page = ($this->uri->segment(3))? $this->uri->segment(3) : 0;
$data["load_rs_report"] = $this->model_ho_por->branch_ho_sr($config["per_page"], $page);
$data["pages"] = $this->pagination->create_links(); 

and got link below but the data are not change,

?dir-move=public&switch=branch_reports&task=branch_report_por&per_page=1
?dir-move=public&switch=branch_reports&task=branch_report_por&per_page=2
?dir-move=public&switch=branch_reports&task=branch_report_por&per_page=3
?dir-move=public&switch=branch_reports&task=branch_report_por&per_page=4
?dir-move=public&switch=branch_reports&task=branch_report_por&per_page=5

Link to comment
Share on other sites

view

<div id="pagination">
<?php echo $pages; ?>
</div>

controller

$config["base_url"] = base_url() . "index.php?dir-move=public&switch=branch_reports&task=branch_report_por";
$config["total_rows"] = $this->model_ho_por->page_count_for_br_por_sr_report(); //return $this->db->count_all('por_ho_request_compile');
$config["per_page"] = 3;
$config["uri_segment"] = 3;
$config['num_links'] = 2;
$config['page_query_string'] = true;
$config['full_tag_open'] = '<ul class="pagination">';
$config['full_tag_close'] = '</ul>';
config['prev_link'] = '<';
$config['prev_tag_open'] = '<li>';
$config['prev_tag_close'] = '';
$config['first_link'] = 'First';
$config['first_tag_open'] = '<li>';
$config['first_tag_close'] = '';
$config['next_link'] = '>';
$config['next_tag_open'] = '<li>';
$config['next_tag_close'] = '';
$config['cur_tag_open'] = '<li class="active"><a href="">';
$config['cur_tag_close'] = '</a></li>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '';
$config['last_link'] = 'Last';
$config['last_tag_open'] = '<li>';
$config['last_tag_close'] = '';
$this->pagination->initialize($config);
$page = ($this->uri->segment(3))? $this->uri->segment(3) : 0;
$data["load_rs_report"] = $this->model_ho_por->branch_ho_sr($config["per_page"], $page);
$data["pages"] = $this->pagination->create_links();

$this->load->view('public/branch_reports/por_sr',$data);

model

$data = array();
$this->db->limit($limit, $start);
$this->db->select('por_ho_request_compile.*,stocks.*,users.*,smr_request_subject.*,por_ho_received_compile.*');
$this->db->select('ufrom.branch_name as branch_from,ufrom.branch_code as from_brc');
$this->db->select('uto.branch_name as branch_to,uto.branch_code as to_brc');
$this->db->select('ho_received.uid,ho_received.first_Name as ho_received_by_fname');
$this->db->select('branch_served.uid,branch_served.first_Name as branch_served_fname');
$this->db->from('por_ho_request_compile');
$this->db->join('stocks','por_ho_request_compile.por_ho_sid = stocks.stock_id','left');
$this->db->join('por_ho_received_compile','por_ho_request_compile.por_id = por_ho_received_compile.por_id','left');
$this->db->join('users','por_ho_request_compile.por_ho_by = users.uid','left');
$this->db->join('users as ufrom','por_ho_request_compile.por_ho_from = ufrom.branch_code','left');
$this->db->join('users as uto','por_ho_request_compile.por_ho_to = uto.branch_code','left');
$this->db->join('users as ho_received','por_ho_received_compile.por_received_uid = ho_received.uid','left');
$this->db->join('users as branch_served','por_ho_request_compile.br_by = branch_served.uid','left');
$this->db->join('smr_request_subject','por_ho_request_compile.por_ho_sbj = smr_request_subject.id_subject', 'left');
$this->db->where('por_ho_request_compile.por_ho_from', $bc);
$this->db->where('por_ho_request_compile.por_ho_temp',4);
$this->db->group_by('por_ho_request_compile.por_id');
$this->db->order_by('por_ho_request_compile.br_sr','desc');
$this->db->order_by('por_ho_request_compile.por_ho_from','asc');
$query = $this->db->get();
				

foreach ($query->result_array() as $row) {
	$data[] = $row;
	}
	return $data;
Edited by Yohanne
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.