2
我想在每個頁面上使用分頁顯示7個結果,但我只在第一頁上顯示7,然後當我點擊下一頁時,它不顯示任何結果。如何從搜索結果中顯示每頁n行
控制器
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);
}
}
型號
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);
}
任何幫助將不勝感激,謝謝。 –