|
楼主 |
发表于 2008-4-23 16:14:39
|
显示全部楼层
现在用session方法做的,问题解决了
我现在把做的例子发上来
控制器
function zjcy_test()
{
$this->load->model('model_zjcy','',true);
$this->load->view('zjcy/test',$data);
}
function test()
{
$this->load->model('model_zjcy','',true);
session_start();
$sw=$this->input->post('sw);//表单中隐藏项,简化条件
if (!empty($sw))
{
if (!empty($_SESSION['toparea']))
{
//session_destroy();
$_SESSION['toparea']='';
$_SESSION['toparea']=$this->input->post('toparea');
$temp=$_SESSION['toparea'];
}
else
{
$_SESSION['toparea']=$this->input->post('toparea');
}
}
else
{
if (empty($_SESSION['toparea']))
{
$_SESSION['toparea']=$temp;
}
}
$this->load->library('pagination');
$count=$this->model_zjcy->test_list();//
$page_cfg['base_url'] = base_url(). "/do.php/zjcy/test/";
$page_cfg['total_rows'] =$count->num_rows();
$page_cfg['per_page'] = '2';
$page_cfg['full_tag_open'] = '<p>';
$page_cfg['full_tag_close'] = '</p>';
$page_cfg['first_link'] = '首页';
$page_cfg['last_link'] = '尾页';
$this->pagination->initialize($page_cfg);
$data['page_links'] = $this->pagination->create_links();
$data['xx'] =$this->model_zjcy->test_list($page_cfg['per_page'],$this->uri->segment(3));
$this->load->view('zjcy/test1',$data);
}
模型 function test_list($num="",$offset="")
{
$this->db->select('*');
$this->db->from('test1');
$this->db->where('toparea', $_SESSION['toparea']);
$this->db->orderby("id", "desc");
$this->db->limit($num,$offset);
$query = $this->db->get();
return $query;
}
我测试过了,应该可以
希望与我有同样问题的朋友有帮助 |
|