public function read()
{
$this->load->library('pagination');
$offset = 0;
$config['base_url'] = base_url("language/read");
$config['per_page'] = 3; // sql query LIMIT number
$offset = ( $this->uri->segment(3) ? $this->uri->segment(3) : 0 );
// set search
if( $this->input->post('search') || $this->input->get('search') ) {
$search = ( $this->input->post('search') ? $this->input->post('search') : $this->input->get('search') );
}
else {
// user has hit return in an empty input field, or has clicked a query link with no property value
$search = NULL;
}
$config['suffix'] = "?search=$search"; // attaches a query onto $this->uri->segment(3), aka $offset
// !issue fix! user searches while offset is out of range of search result
if( $offset != 0 && $this->input->post('search') ){
redirect("language/read/0?search=$search");
}
// !issue fix! user searches while no GET query is in URL
if( $offset != 0 && $this->input->get('search') === NULL ){
redirect("language/read/0?search=$search");
}
$this->data['languages'] = $this->language_model->get_languages_pagnation($config['per_page'], $offset, $search);
$config['total_rows'] = $this->db->query("SELECT id FROM languages WHERE title LIKE '%$search%'")->num_rows();
$config['first_url'] = "0?search=$search"; // explicitly set this to the first link
$this->pagination->initialize($config);
$this->data['pagination'] = $this->pagination->create_links();
$this->render('language');
}