|
表单输入 起始时间 终止时间 来获取数据库的数据。
第一页显示正常,点击第二页就无任何数据提取出来。好像是表单传入的值不起作用了。
这是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();
?> 复制代码 |
|