用户
 找回密码
 入住 CI 中国社区
搜索
查看: 3224|回复: 3
收起左侧

[HELP] 带表单传值的分页如何实现?

[复制链接]
发表于 2010-3-29 13:05:19 | 显示全部楼层 |阅读模式
表单输入  起始时间  终止时间  来获取数据库的数据。
第一页显示正常,点击第二页就无任何数据提取出来。好像是表单传入的值不起作用了。
这是Model的部分代码:
PHP复制代码
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的部分代码:
PHP复制代码
               
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复制代码
<?php
 
echo $this->table->generate($records);
echo $this->pagination->create_links();
?>
复制代码
发表于 2010-3-29 13:36:44 | 显示全部楼层
 楼主| 发表于 2010-3-29 17:13:05 | 显示全部楼层
多谢版主!要的就是这个效果。太感谢了!!好好研究研究!
发表于 2012-2-14 23:52:26 | 显示全部楼层
http://codeigniter.org.cn/forums ... 36&fromuid=6570

链接打不开了。为什么啊?

本版积分规则