Reputation: 103
I want to display 7 results on every page using pagination but I'm only getting it on first page 7 and then when i click next page it does not display any result.
Controller
function display($offset=0)
{
$limit=7;
$select = $this->input->post('select');
$name = $this->input->post('name');
if($select=='none')
{
echo '<script>alert("please Select college");</script>';
$this->load->library('user_agent');
$page_url=$this->agent->referrer();
redirect($page_url,'refresh');
}
else
{
$result['numOfRows']=$this->getmodel2->countRows();
$this->load->library('pagination'); #2
$this->load->library('table');
$config=array(
'base_url'=> site_url('Verify3/display/?name='.$name),
'total_rows'=> $result['numOfRows'][0]['count'],
'per_page'=>$limit,
'page_query_string' => TRUE,
'num_links'=>2
);
$result['j']=$this->getmodel2->getSearchbook($limit,$offset,$name,$select); #3
$this->pagination->initialize($config); #4
$result['pagination']=$this->pagination->create_links(); #5
$this->load->view('imageview3',$result);
}
}
Model
function getSearchBook($limit,$offset,$name,$select) {
$query="Select * from home where ownerid='$name' and select='$select limit $limit offset $offset";
$result_query= $this->db->query($query);
}
Upvotes: 2
Views: 603
Reputation: 342
you can use a session to store your input data and send session data in the query.
if ($name!=NULL&&$select!=NULL) {
$session_data = $this->session->userdata('search_data');
$session_data['search'] = $name;
$session_data['search'] = $select;
$this->session->set_userdata('search_data', $session_data);
}
$result['j']=$this->getmodel2->getSearchbook($limit,$offset,$this->session->userdata['search_data']['search'],$this->session->userdata['search_data']['select']);
Upvotes: 1