codeigniter的分页在第一个链接上不起作用

时间:2012-03-16 22:42:27

标签: php codeigniter pagination

$config['suffix'] = '?'.http_build_query($_GET, '', "&");

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

编辑:

$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);

所以,我使用get来构建用户之前提交的查询(这是一个搜索功能 - 所以get是必要的)而不是获取页面的数量!希望这更清楚。

1 个答案:

答案 0 :(得分: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而不使用它们作为参数,你应该避免这样的实现。

相关问题