2012-03-16 74 views
1
$config['suffix'] = '?'.http_build_query($_GET, '', "&"); 

我在使用get post的控制器中的函数使用codeigniter的分页类。一切正常。链接生成,我可以去每一页等 但是,当我先点击它带我到的网址:http://www.example.com/controller/function/ 并忽略我要求它追加在该函数的末尾的后缀。 例如,当2是我的当前页面,并且我打1时,它不起作用: 1,2,4,5,6,... 当它自动将我带到第一个链接,即第1页时,它全部起作用罚款。codeigniter的分页不能在第一个链接上工作

编辑:

$this->load->library('pagination'); 
     $config['suffix'] = '?'.http_build_query($_GET, '', "&"); 
     $config['base_url'] = 'http://www.example.com/controller/function'; 
     $config['total_rows'] = count($results); 
     $config['per_page'] = 15; 
     $config['num_links'] = 3; 
$this->pagination->initialize($config); 

所以,我现在用的是得到建立,用户先前提交的(这是一个搜索功能 - 所以得到的是必要的)查询,并没有获得页面的数量!希望这更清楚。

回答

0

- 确保你有你的

$config['base_url'] = 'http://example.com/index.php/controller/pagination_function/' 

设置到正确的位置。

- 为什么你使用$ _GET ['']?你应该使用codeigniter的内置

$this->uri->segment(n) 

前。

http://website.com/mycontroller/myfunction/myname/mybirthday 
$name = $this->uri->segment(3); 
$birthday = $this->uri->segment(4); 

你也应该知道,在URL后的功能URI空间的参数,以上述功能,如果任意添加的URI之后,而不是利用他们作为参数,你应该避免这样的实现。

+0

我更新了问题以澄清事情。谢谢你的回答! – 2012-03-17 21:42:54