带表单传值的分页如何实现?
表单输入起始时间终止时间来获取数据库的数据。第一页显示正常,点击第二页就无任何数据提取出来。好像是表单传入的值不起作用了。
这是Model的部分代码:
function getData($num,$offset){
$data = array();
$starttime = $this->input->post('starttime');
$endtime = $this->input->post('endtime');
$where = array('powertime >=' => $starttime,'powertime <=' => $endtime);
$query = $this->db->get_where('jnydlr',$where,$num,$offset);
if ($query->num_rows() > 0 ){
foreach ($query->result_array() as $row){
$data[] = $row;
}
}
else{
echo "请输入时间";
}
$query->free_result();
return $data;
}
这是controller的部分代码:
function index()
{
$this->load->library('pagination');
$config['base_url']='http://192.168.2.44/jieneng/index.php/jnyssj/index/';
$config['total_rows']= $this->db->get('jnydlr')->num_rows();
$config['per_page']=10;
$config['num_links']=10;
$config['first_link'] = "首页";
$config['last_link'] = "尾页";
$config['prev_link'] = "上一页";
$config['next_link'] = "下一页";
$config['full_tag_open'] = '<div id="pagination">';
$config['full_tag_close'] = '</div>';
$this->pagination->initialize($config);
$data['records'] = $this->jnyssjmodel->getData($config['per_page'],$this->uri->segment(3));
$this->load->view('jnyssj_vv',$data);
这是View的部分代码:
<?php
echo $this->table->generate($records);
echo $this->pagination->create_links();
?> http://codeigniter.org.cn/forums/viewthread.php?tid=4936&fromuid=6570 多谢版主!要的就是这个效果。太感谢了!!好好研究研究! http://codeigniter.org.cn/forums ... 36&fromuid=6570
链接打不开了。为什么啊?
页:
[1]