0
我已經實施與分頁搜索。 控制器功能`公共函數搜索() {Codeigniter搜索與分頁
if($_POST)
{
$search_name=$this->input->post('search_name');
$config['base_url'] = 'search';
$config['total_rows'] = 15;//$this->registration_model->record_count();
$config['per_page'] = 4;
$config["uri_segment"] = 3;
$config['use_page_numbers'] = TRUE;
$this->pagination->initialize($config);
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$data['result']=$this->institute_model->search_result($config["per_page"],$page,$search_name);
$data['links'] = $this->pagination->create_links();
$this->load->view('institute/search',$data);
}
}`
和型號的功能碼是
public function search_result($limit,$start,$search_name)
{
$this->db->limit($limit, $start);
$this->db->select('user_id');
$this->db->where('category',1);
$this->db->like('first_name',$search_name);
$query = $this->db->get('registration');
if ($query->num_rows() > 0) {
foreach ($query->result() as $row) {
$data[] = $row;
}
return $data;
}
return false;
}
我從登記表具有用戶ID和FNAME等搜索是基於用戶名搜索。它適用於我,但是當我點擊分頁上的第2頁時,它會轉到http://localhost/mypro/index.php/institute/search/2
並變爲空白。加載視圖之前
好。現在,到目前爲止做了什麼?或者你只是想要一個現成的腳本? – 2012-04-08 11:22:15
請遵循以下教程:http://www.w3schools.com/php/php_ajax_livesearch.asp如果您遇到任何問題,請先做一些調查,如果您仍然無法找到解決方案,請在此處尋求幫助,包括您的質疑迄今爲止你所嘗試過的東西。 – alxbrd 2012-04-08 11:26:42