【发布时间】:2014-09-23 00:23:36
【问题描述】:
CI 开发者我的要求是:
我想将可以在我的视图页面(即我的结果页面)上运行的分页脚本。
$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['showdata']=$this->searchresultss->login($per_page,$look,$age, $age_to,$age_from,$se_ct,$subsect,$coun_try,$sta_te, $ci_ty,$qualification);
$this->load->view('searchresult',$data);
下面是我的模型:
public function login ($per_page=3,$look,$age,$age_to,$age_from,$se_ct,$subsect,$coun_try, $sta_te, $ci_ty,$qualification)
{
$query="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'";
$data=array();
$query=$this->db->query($query);
$data['results']=$query->result_array();
$data['count']=$query->num_rows();
$data['pages']=ceil($data['count']/3);
return $data;
}
下面是我的结果页面,即查看页面
<?php
if (isset($showdata)){
foreach ($showdata['results'] as $k => $v) {
?>
<?php echo $v['gender']; echo $v['email'];?>
<?php
}
}
echo $showdata['count']; echo $showdata['pages'];
?>
这里开始我的问题,我发布了完整的控制器、模型、视图 o/p 我做了什么,我想要有人可以帮助我编辑我的模型、控制器、视图,它可以在分页中显示结果。
我是全新的 CI,所以如果需要,我请求所有 CI 人员帮助我编写分页脚本,您可以完全编辑我的模型、控制器和视图。
我会感谢那些可以帮助我的人。
【问题讨论】:
-
您不应期望我们提供任何服务。我们在这里向您展示正确的方向,而不是提高您的期望。请从您的文本中删除代码格式。只有代码应该在
code format。 -
你应该学会更好地格式化你的问题。如果你想让别人为你付出努力,你应该先为自己付出一些
-
你说的是对的,我正在尝试 3 天,但我失败了,所以我简要地发布了我的问题。我编辑了你所说的 machineaddict 先生。
-
Vicky,仍有正常的问题文本格式化为代码。请花几分钟时间来纠正它。保存时,查看问题以查看其格式是否正确。
-
您是否将其他任何内容传递给控制器方法?控制器方法的名称是什么?这个页面的网址是什么?
标签: php codeigniter pagination