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


codeigniter's pagination does not work on first link

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

我正在使用代码点火器的分页类来使用控制器中使用 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是必要的(,而不是获取页面编号!希望这更清楚。

- 确保你有你的

$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并且不将它们用作参数,则应避免此类实现。