分页正确,但是分页后的数据不变
控制器function index()
{
$this->load->library("session");
@$data = $this->session->userdata('uid');
$this->load->model('testm');
$this->load->library('pagination');
$this->load->library('table');
$fkeyword=trim($this->input->get('keyword', TRUE));
$config['base_url'] = 'http://localhost/CodeIgniter_2.1.4/index.php/home/index?keyword='.$fkeyword.'';
//$config['base_url'] = 'http://localhost/CodeIgniter_2.1.4/index.php/home/index/'.$fkeyword.'';
$config['total_rows'] = $this->testm->user_select_count($fkeyword);
$config['per_page'] = 2;
$config['first_link'] = '第一页';
$config['last_link'] = '最后一页';
$config['prev_link'] = '上一页';
$config['next_link'] = '下一页';
$config['num_links'] = 4;
$config['page_query_string'] = TRUE;
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$this->pagination->initialize($config);
//$this->table->set_heading('ID', 'Title', 'Author', 'Description'); //利用表格类,可以生成头部
$data['results'] = $this->testm->user_selectall($page,$config['per_page'],$fkeyword);
$this->load->view("home",$data);
}
model中的
//计算总数
function user_select_count($fkeyword)
{
$this->db->count_all_results();
$this->db->like('uname',$fkeyword);
$query = $this->db->get('user');
return $query->num_rows();
}
//查询多个
function user_selectall($segment,$per_page,$fkeyword)
{
//$sql='select * from user where uname like '%xiaoqing%' limit '.$segment.','.$per_page;
//$query=$this->db->query($sql);
//return $query->result_array();
$this->db->like('uname',$fkeyword);
$this->db->select("*");
$query=$this->db->get("user",$per_page,$segment);
echo "$fkeyword"."<br/>";
print_r($query->result_array());
return $query->result_array();
}
谁能告诉我为什么啊。 $config['base_url'] = 'http://localhost/CodeIgniter_2.1.4/index.php/home/index?keyword='.$fkeyword.'';
url写的有问题 官方的分页类只是帮助我们简单的生成url。
对于具体url的处理还需要我们自己写。 zhanggen123 发表于 2013-8-20 12:16 static/image/common/back.gif
$config['base_url'] = 'http://localhost/CodeIgniter_2.1.4/index.php/home/index?keyword='.$fkeyword.' ...
谢谢了。我已经晓得问题了。在index后面加上 "/" 就行了,就在这里犯错误了。{:soso_e113:}
$config['base_url'] = 'http://localhost/CodeIgniter_2.1.4/index.php/home/index/?keyword='.$fkeyword.'
页:
[1]