[eluser]R_Nelson[/eluser]
I have a list of over 7000 songs the index function shows all of them with pagination the search will show the first 20 but when you go to the 2nd page it goes to the normal 2nd page from index.
Updated : what i'm am trying to do is use the same view page do display the search and the full list but what is happening is i'm losing the search when i try to go to a 2nd page with pagination not sure how to fix it.
Code:
function index()
{
$this->load->library('pagination');
$this->load->library('table');
$this->table->set_heading('', 'Song Name', 'Artist');
$config['base_url'] = 'http://whitetigerdj.com/karaoke/index/';
$config['total_rows'] = $this->db->get('karaoke')->num_rows();
$config['per_page'] = 20;
$config['num_links'] = 10;
$config['full_tag_open'] = '<div id="pagination">';
$config['full_tag_close'] = '</div>';
$this->pagination->initialize($config);
$str = $config['total_rows'];
$this->load->model('Right_model');
$data['right'] = $this->Right_model->show_right();
$data['query'] = '';
$data['songs'] = $this->_limitchars($str);
$data['records'] = $this->db->get('karaoke', $config['per_page'], $this->uri->segment(3));
$data['title'] = 'Karaoke List';
$data['discription'] = '';
$data['keyword'] = '';
$data['main_content'] = 'karaoke/karaoke_list';
$this->load->view('includes/template', $data);
}
function search()
{
$this->load->library('pagination');
$this->load->library('table');
$this->table->set_heading('', 'Song Name', 'Artist');
$config['base_url'] = 'http://whitetigerdj.com/karaoke/search/';
$config['per_page'] = 20;
$query = $this->input->post('query');
$data['query'] = $query;
$data['records'] = $this->db->or_like('song_name',$query)->or_like('artist',$query)->get('karaoke',$config['per_page'], $this->uri->segment(3));
$config['total_rows'] = $this->db->or_like('song_name',$query)->or_like('artist',$query)->get('karaoke')->num_rows();
$data['rows'] = $config['total_rows'];
$config['num_links'] = 10;
$config['full_tag_open'] = '<div id="pagination">';
$config['full_tag_close'] = '</div>';
$this->pagination->initialize($config);
$str = $this->db->get('karaoke')->num_rows();
$this->load->model('Right_model');
$data['right'] = $this->Right_model->show_right();
$data['songs'] = $this->_limitchars($str);
$data['title'] = 'Karaoke List';
$data['discription'] = '';
$data['keyword'] = '';
$data['main_content'] = 'karaoke/karaoke_list';
$this->load->view('includes/template', $data);
}