我對代碼點火器有點麻煩,自今早4點起工作,我的大腦處於關閉模式。CodeIgniter分頁
我有這樣的代碼,
public function books($Page = 0)
{
$config['base_url'] = base_url('user/books');
//Recherche des livres
$SubSearch = $this->input->post('SubSearch');
//Nombre occurence par page
$SubPerPage = $this->input->post('SubPerPage');
//Configuration du mode d'affichage de tout les livres
//Gestion du champ de recherche
if(isset($SubSearch))
{
$this->session->set_userdata('BookSearch',$this->input->post('Search'));
}
//Gestion du nombre par page
if(isset($SubPerPage))
{
$this->session->set_userdata('PerPage',$this->input->post('PerPage'));
}
//Gestion nombre affichage per page
if(!empty($this->session->userdata('PerPage')))
{
$config['per_page'] = $this->session->userdata('PerPage');
}else
{
$config['per_page'] = 10;
}
//La Requette
if(!empty($this->session->userdata('BookSearch')))
{
$config['total_row'] = $this->functions->getSearch($this->session->userdata('BookSearch'),"","")->num_rows();
$query = $this->functions->getSearch($this->session->userdata('BookSearch'),$Page,$config['per_page']);
}else
{
$config['total_row'] = $this->db->query('SELECT * FROM books')->num_rows();
$query = 'SELECT * FROM books LIMIT '.$Page.','.$config['per_page'].'';
$query = $this->db->query($query);
}
$data['BooksSearchQuery'] = $query->result();
echo 'perpage : '.$config['per_page'];
echo 'total row : '.$config['total_row'];
$this->pagination->initialize($config);
$this->load->view('user/books',$data);
}
但create_links給什麼,而值
echo 'perpage : '.$config['per_page'];
echo 'total row : '.$config['total_row'];
都不錯。 解決方案?先行先謝謝
$ data ['BooksSearchQuery']是否有任何行?首先嚐試使用var_dump。 – Rahi
感謝您的回覆,BooksSearchQuery上的var_dump告訴我我有10個尺寸,沒關係。 –
如果你只有10行並且你的配置設置爲10,那麼沒有鏈接可以創建。嘗試將配置設置爲5.'$ config ['per_page'] = 5;' – hayres