Search result not working after second page of pagination

Viewed 403

i'm beginner in Codeigniter and everything works well , but i have one problem , i made search and that reply with a correct results but i press to the second page i got error , i searched to much and saw a topic talking about session but not working with me

That is my controller

public function search(){
        $this->load->library('pagination');
        $this->load->helper("url");
        $this->load->model(array('CustomReport_m','user','Customer_m')); // This array to save number of lines only
        $username=$this->input->post('select_user');
        $total_row = $this->CustomReport_m->search_count($username);
        $config['page_query_string'] = TRUE;
        $config['base_url'] = base_url().'CustomReport/search/';
        $config['total_rows'] = $total_row;
        $config['per_page'] = 5;
        $config['full_tag_open'] = '<ul class="pagination">';
        $config['full_tag_close'] = '</ul>';
        $config['first_link'] = false;
        $config['last_link'] = false;
        $config['first_tag_open'] = '<li>';
        $config['first_tag_close'] = '</li>';
        $config['prev_link'] = '&laquo';
        $config['prev_tag_open'] = '<li class="prev">';
        $config['prev_tag_close'] = '</li>';
        $config['next_link'] = '&raquo';
        $config['next_tag_open'] = '<li>';
        $config['next_tag_close'] = '</li>';
        $config['last_tag_open'] = '<li>';
        $config['last_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>';
        $this->pagination->initialize($config);
        if ($this->uri->segment(2)) {
            $page = ($this->uri->segment(2));
        } else {
            $page = 1;
        }
        $str_links = $this->pagination->create_links();
        $data["links"]= explode('&nbsp;', $str_links);
        $data['users']=$this->user->display_users();
        $data['userdata'] = $this->user->userdata();
        $data['customers']= $this->Customer_m->index();
        if(isset($username)and !empty($username)){
              $data["rsl"] =$this->CustomReport_m->search($username,$config["per_page"],$page);
            //$data["rsl"] = $this->CustomReport_m->search($config["per_page"],$page,$username);
            $this->load->view('customreport_v',$data);
        }else{
            redirect('CustomReport','refresh');
        }
    } 

That is my Model

public function search_count($username) {
        $this->db->like('t_u_id',$username);
        return $this->db->count_all("transactions");
    }
    public function search($username,$limit,$start)
    {
        $this->db->select('*');
        $this->db->limit($limit,$start);
        $this->db->from('transactions');
        $this->db->like('t_u_id',$username);
        $query=$this->db->get();
        if($query->num_rows() > 0){
            return $query->result();
        }else{
            return $query->result();
        }
    }
2 Answers
Related