//控制器
功能搜索($ 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'] = '«';
$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'] = '»';
$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);
}
//模型 function search_employee($ searchemployee) { $ sql =“选择Empcode,来自spmm_employee_info的名称,其名称与'%'相同。 $ searchemployee。 “%'”; $ query = $ this-&gt; db-&gt; query($ sql); return $ query-&gt; result_array(); }
当我尝试搜索并单击其他页面时,它会显示表spmm_employee_info上的所有数据。我想要的是显示与搜索相关的所有结果,而不是当我点击分页上的页面时显示所有数据。请帮忙
答案 0 :(得分:0)
使用mysql DATE_FORMAT 并转换日期时间就像这个演示查询一样
SELECT DATE_FORMAT(colName,'%H:%i:%s') TIMEONLY from tbl where TIMEONLY='7:01AM'