0
votes

//Controller

function search($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);

}

//Model function search_employee($searchemployee) { $sql = "select Empcode, Name from spmm_employee_info where name like '%" . $searchemployee . "%'"; $query = $this->db->query($sql); return $query->result_array(); }

When i try to search and click on the other page, it displays all the data on the table spmm_employee_info. All i want is to display all the results related to the search and not all data when i click the page on the pagination. Please help

1
Should us your table definitions please. This looks like you want some sort of pivot, but then again you left out some vital information.Tim Biegeleisen

1 Answers

0
votes

Use mysql DATE_FORMAT and convert date time in time Like this demo query

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