简体   繁体   中英

codeigniter pagination link is not working when i select the link

Request yo to help in pagination links . In my database i have 3 records i want to display single record per page. When I select the next numeric of pagination link, data is not being fetched.Thing is that when I click on number 2 of pagination link, echo var_dump() shows Result is empty and I am not getting any values for echo $data->email.But for the first time when i search i am able to display single record, problem is only with next link of pagination So what might be the error? I'm not able to get an answer,and I'm not sure what happens, so I am posting my code below please go through it and and help me. Request you to help me.

**HERE STARTS MY CONTROLLER**

 public function users($limit=1,$offset = 0)
{
$this->load->helper('url');
$data = array();
$look = $this->input->post('look');
$age = $this->input->post('age');
$age_from = $this->input->post('age_from');
$age_to = $this->input->post('age_to');
$se_ct = $this->input->post('sect');
$subsect = $this->input->post('subsect');
$coun_try = $this->input->post('country');
$sta_te = $this->input->post('state');
$ci_ty = $this->input->post('city');
$qualification = $this->input->post('qualification');
$results = $this->searchresultss->login($look, $age, $age_to, $age_from, $se_ct, $subsect, $coun_try, $sta_te, $ci_ty, $qualification);
$this->load->helper('url');
$config = array();
$config['base_url'] = base_url().'searchresult/users';
$config['total_rows'] = count($results);
$config['per_page'] = $limit;
$this->load->library('pagination', $config);
$data['pagination_links'] = $this->pagination->create_links();
$data['results'] = array_slice($results, $offset, $limit);
 $this->load->view('searchresult', $data);
$this->load->view('includes/khelp');
$this->load->view('includes/kfooter');


**HERE STARTS MY MODEL PAGE**

     Class Searchresultss extends CI_Model
            {

            public function login($look, $age, $age_to, $age_from, $se_ct, $subsect, $coun_try, $sta_te, $ci_ty, $qualification)
            {

                    return $this->db->query("SELECT *
                    FROM users
                    WHERE   gender = '$look'
                    And status='1'")->result();

             }

            }


**HERE START MY VIEW PAGE**
echo var_dump($_POST);
if (empty($results)) {
 echo 'Results set is empty';
        } else 
        {
        foreach ($results as $data) {
                echo $data->email.'<br />';
            }

        }
        echo $pagination_links;

The problem lies in the fact that the pagination links do not include the POST variables (as well as the fact that hyper links are requested via GET). I recommend you do a var_dump() on $_GET and $_POST and the problem will become more obvious.

A possible solution would be to include the post variables as url parameters. So for example

$config['base_url'] = base_url().'searchresult/users/look_param/age_param/etcetc';

However you would need to add functionality to handle the above.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM