codeigniter中的分页链接无法正常工作

时间:2014-08-01 08:26:25

标签: php codeigniter pagination

分页链接显示正常。

但是,当我选择链接2时,结果未显示且网址正在更改为/kkci/searchresult/users/1,而应更改为/kkci/searchresult/users/2

当我选择下一个数字链接时,未提取数据。

那么可能是错误我不确定所以我在下面发布我的代码请仔细阅读并帮助我。

当我点击分页链接echo var_dump()的第2号时,显示结果为空,而且我没有获得echo $data->email的任何值。

我也无法通过谷歌获得答案但是,当我选择分页链接时,当页面加载问题无法正常工作时,会显示一个已录制的内容。

我是CI的新手,要求CI人帮我显示分页2和3的结果。总共有3条记录我正在显示单页记录。

控制器:

public function users($limit=1,$offset = 0)
{

    $this->load->helper('url');
    $this->load->library('session');
    if ($postdata = $this->session->flashdata('post_data')) {
        foreach (unserialize($postdata) as $key => $value) {
            $_POST[$key] = $value;
        }
    }

    $this->session->set_flashdata('post_data', serialize($this->input->post()));
    $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);

    //for base_url()
    $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);

    // BELOW IS MY MODEL
    if (empty($results)) {
        echo 'Results set is empty';
    } else {
        foreach ($results as $data) {
            echo $data->email.'<br />';
        }
    }

    echo $pagination_links;//Iam able to display pagination link in my view page.
}

型号:

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(); //Returning this to controller

 }

查看:

if (empty($results)) {
    echo 'Results set is empty';
} else {
    echo '<pre>';
    echo var_dump($results); 
    foreach ($results as $data) {
        echo $data->email.'<br />'; 
    }
}
echo $pagination_links;

0 个答案:

没有答案