簡體   English   中英

分頁在Codeigniter

[英]Pagination on Codeigniter

//控制器

函數搜索($ search = 0){

    $this->form_validation->set_rules("search", "Search", "trim|required|xss_clean");

            $searchemp = $this->input->post('search');
            $data['result'] = $this->main_model->search_employee($searchemp);
            $data['resultcount'] = count($this->main_model->search_employee($searchemp));
            //$result = $this->main_model->search_employee($searchemp);

            //$this->display($this->main_model->search_employee($searchemp));
            $config['base_url'] = base_url().'main/search';
            $config['anchor_class'] = 'test';
            $config['total_rows'] = $data['resultcount'];
            $config['per_page'] = 10;
            $config['num_links'] = 5;
            $config['use_page_numbers'] = TRUE;
            $config['full_tag_open'] = '<ul class="pagination">';
            $config['full_tag_close'] = '</ul>';
            $config['prev_link'] = '&laquo;';
            $config['prev_tag_open'] = '<li>';
            $config['prev_tag_close'] = '</li>';
            $config['next_tag_open'] = '<li>';
            $config['next_tag_close'] = '</li>';
            $config['cur_tag_open'] = '<li class="active"><a href="#">';
            $config['cur_tag_close'] = '</a></li>';
            $config['num_tag_open'] = '<li>';
            $config['num_tag_close'] = '</li>';
            $config['next_link'] = '&raquo;';


           $this->pagination->initialize($config);
            $tmpl = array ( 'table_open' => '<table class="table table-bordered table-hover">' );
            $this->table->set_template($tmpl);
            //$data['searchresult']=$this->db->get($result, $config['per_page'],$search);// take record of the table
            $header = array('Employee Number','Name'); // create table header
            $this->table->set_heading($header);// apply a heading with a header that was created
            $this->load->view('results_view',$data);

}

//模型函數search_employee($ searchemployee){$ sql =“選擇Empcode,名稱來自spmm_employee_info,名稱類似於'%”。 $ searchemployee。 “%'”; $ query = $ this-> db-> query($ sql); 返回$ query-> result_array(); }

當我嘗試搜索並單擊另一頁時,它將在表spmm_employee_info上顯示所有數據。 當我單擊分頁上的頁面時,我只想顯示與搜索相關的所有結果,而不是所有數據。 請幫忙

使用mysql DATE_FORMAT並及時轉換日期時間

SELECT DATE_FORMAT(colName,'%H:%i:%s') TIMEONLY from tbl where TIMEONLY='7:01AM'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM