我收到错误不支持的操作数\libraries\Pagination.php当我尝试把结果页上的pagenation [英] I am getting error unsupported operands \libraries\Pagination.php when i try to put pagenation on result page

查看:166
本文介绍了我收到错误不支持的操作数\libraries\Pagination.php当我尝试把结果页上的pagenation的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

**This is my controller**
$this->load->library("pagination");  
$this->load->helper('url');
$this->load->view('includes/kheader');
$this->load->view('includes/kmenu');

$per_page=$this->input->post('per_page');
$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');

        $data['base']=$this->config->item('base_url');
        $data['title']= 'Message form';
        $this->load->model("searchresultss");
     $per_pg=1;
        $offset=$this->uri->segment(2);
        $total=$this->searchresultss->login($per_pg,$offset,$per_page,$look,$age, $age_to,$age_from,$se_ct,$subsect,$coun_try,$sta_te, $ci_ty, $qualification);


        $this->load->library('pagination');
        $config['base_url'] = $data['base'].'/searchresult/users/';
        $config['total_rows'] = $total;
        $config['per_page'] = $per_pg;
        $config['full_tag_open'] = '<div id="pagination">';
        $config['full_tag_close'] = '</div>';

        $this->pagination->initialize($config);
        $data['pagination']=$this->pagination->create_links();

        $data['query']=$this->searchresultss->login($per_pg,$offset,$per_page,$look,$age, $age_to,$age_from,$se_ct,$subsect,$coun_try,$sta_te, $ci_ty,$qualification);
    $this->load->view('searchresult',$data);

**这是我的模型**

**This is my model **

 public function login($per_page=3,$look,$age,$age_to,$age_from,$se_ct,$subsect,$coun_try, $sta_te, $ci_ty,$qualification,$per_pg,$offset)
 {
       $query=$this->db->get('users',$per_pg,$offset);
        return $query->result();
 }
     public function message_count()
    {
        return $this->db->count_all("SELECT *
FROM users
WHERE  

if('$se_ct'!='',sect =  '$se_ct' AND if('$subsect' !='',subsect =  '$subsect',subsect like  '%%'),sect like  '%%' AND subsect like  '%%')
AND
IF( '$coun_try' !='', country =  '$coun_try'
AND 
if('$sta_te' !='', state =  '$sta_te'
AND  
if('$ci_ty' !='',city =  '$ci_ty',city like  '%%'),state LIKE  '%%'
AND city LIKE  '%%'), country LIKE  '%%'
AND state LIKE  '%%'
AND city LIKE  '%%' ) 
AND age >=  '$age_from'
AND age <=  '$age_to'
AND 
IF('$qualification' !='',qualification =  '$qualification',  qualification LIKE  '%%' ) 
And gender = '$look'
And status='1'");
    }

我是新的ci框架的东西是iam试图把分页放在我的结果页面在abeobe提到的方式,当我这样做iam得到错误不支持的操作数\libraries\pagination.php所以请求您帮助我
致命错误:不支持的操作数类型在 H:\ xampp \htdocs\kkci\system\libraries\Pagination.php在第124行上是错误什么iam获取

I am new to ci framework thing is that iam trying to put pagination on my result page in abeobe mentioned way when i do so iam getting error unsupported operands \libraries\pagination.php so request you to help me Fatal error: Unsupported operand types in H:\xampp\htdocs\kkci\system\libraries\Pagination.php on line 124 is the error what iam getting

推荐答案

您的问题是您将数组而不是数字分配到 $ config ['total_rows']

Your problem is that you are assigning an array instead of a number into $config['total_rows']

您可以通过调用模型中的登录函数获取此值。

You get this value by calling the login function in your model.

$total=$this->searchresultss->login($per_pg,$offset,$per_page,$look,$age, 
$age_to,$age_from,$se_ct,$subsect,$coun_try,$sta_te, $ci_ty, $qualification);

那么你分配 $ config ['total_rows'] = $ total;

then you assign it $config['total_rows'] = $total;

但是在你的模型中,函数写成返回一个数组:

However in your model the function is written to return an array:

  public function login($per_page=3,$look,$age,$age_to,$age_from,$se_ct,
  $subsect,$coun_try, $sta_te, $ci_ty,$qualification,$per_pg,$offset)
     {
           $query=$this->db->get('users',$per_pg,$offset);
            return $query->result(); //this is an array that is returned
     }

为了解决这个问题,我相信你可以将结果集的计数分配给total_rows变量:

To fix this, I believe you can assign the count of the resultset to the total_rows variable:

$config['total_rows'] = count($total);

这篇关于我收到错误不支持的操作数\libraries\Pagination.php当我尝试把结果页上的pagenation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆