代码点火器分页下一个链接不显示数据库中的记录


codeigniter pagination next link not displaying record from database

我是CI的新手,所以伙计们请求帮助我显示分页链接的结果。在数据库中,我有3条记录,我为每个页面显示一条记录。

当我选择不显示分页结果的下一个数字链接时,问题出现在我的分页链接中。

问题是,当我点击分页链接的第2个输出时,显示$results为空,并且我没有得到echo$data->email的任何值。

我也无法通过谷歌得到答案。但当页面加载的问题是当我选择下一个数字链接的分页链接时,显示了一条记录,它不起作用。分页脚本无法正常工作,我认为这与偏移有关。

这是我的控制器

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 is my view page**
if (empty($results)) {
    echo 'Results set is empty';
} else {
foreach ($results as $data) {
        echo $data->email.'<br />';
    }
}
echo $pagination_links;
//Error is when i select next numeric link of pagination record is not being fetched from database getting output as emty result in my view page.so request you to help me in solving the issue and more warning message is  missiing argument 2 for Searchresult::users() , and more errror message is undefined variable offset .

首先,不需要传递100个您甚至不使用的参数,去掉这些参数。

现在来看代码。

function login($look, $page = 0, $offset = 1){
    $query = $this->db->get_where('users', array('gender' => $look, 'status' => '1'), $limit, $offset);
    return $query;
}

这应该行得通。

第一个分页配置:-

   $config['base_url'] = base_url() . 'controller_name/function_name/';
   $config['per_page'] = 20;    //lets say 20 record per page 
   $config['total_rows'] = $total_rows;
   $this->pagination->initialize($config);

根据分页配置从数据库获取数据

  $start = $this->uri->segment(3, 0);
  $queryNum = $this->db->get('table_name');
    $num = $queryNum->num_rows();
    if ($num > 0) {
        $config['total_rows'] = $num; //reset total rows
        $this->db->limit($config['per_page'], $start);
        $queryNum1 = $this->db->get('table_name');
        foreach ($queryNum1->result() as $rows) {
            $tmp[] = $rows; //holds the query result data
        }
     }
    $data1['pagination'] = $this->pagination->create_links();