请求哟帮助分页链接。 在我的数据库中,我有3条记录,我想在每页显示单条记录。当我选择下一个分页链接数时,数据没有被提取。当我点击分页链接的第2个时,echo var_dump()显示Result为空,我没有获得echo $ data-&gt的任何值;电子邮件。但是当我第一次搜索我能够显示单个记录时,问题只出现在下一个分页链接那么可能是什么错误?我无法得到答案,而且我不确定会发生什么,所以我在下面发布我的代码请仔细阅读并帮助我。 请求你帮助我。
**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;
答案 0 :(得分:0)
问题在于分页链接不包括POST变量(以及通过GET请求超链接的事实)。 我建议你在$ _GET和$ _POST上做一个var_dump(),问题就会变得更加明显。
可能的解决方案是将post变量包含为url参数。例如,
$config['base_url'] = base_url().'searchresult/users/look_param/age_param/etcetc';
但是,您需要添加处理上述内容的功能。