0

问题是在分页中,我还没有显示数据库的东西,但问题不在于那个。

问题是我已经显示了页面链接,但是当我单击第 2 页的链接时,它转到

http://127.0.0.1:8887/codeigniter-tests/index.php/pagination/index/127.0.0.1:8887/codeigniter-tests/index.php/pagination/index/5
.

如您所见,该链接基本上重复了两次,现在如果我在第 2 页上单击 1,它将带我到

http://127.0.0.1:8887/codeigniter-tests/index.php/pagination/index/127.0.0.1:8887/codeigniter-tests/index.php/pagination/index/127.0.0.1:8887/codeigniter-tests/ index.php/分页/索引/

如您所见,现在它已经写了三次,如果我在此页面上单击 2,它会再次附加 url 并将我带到那里:/

现在我想问为什么会这样???

代码如下:_

控制器(分页.php)

类分页扩展 CI_Controller {

function index() {
    $this->load->library('pagination');

    $config['base_url'] = '127.0.0.1:8887/codeigniter-tests/index.php/pagination/index/';
    $config['total_rows'] = $this->db->get('data')->num_rows;
    $config['per_page'] = 5;
    $config['num_links'] = 10;
    $config['uri_segment'] = 3;

    $this->pagination->initialize($config);

    $data['records'] = $this->db->get('data', $config['per_page'], $config['uri_segment']);
    $this->load->view('pagination_view', $data);


}

}

这是视图(pagination_view.php):_

<html>  
<head>  
    <title>CI Pagination</title>  
</head>  
<body>  
    <h1>Pagination With CI</h1> 
    <?php
        echo $this->pagination->create_links();
    ?>
</body>  
</html>  

只是一些额外的信息,如果我将 $config['base_url'] 设置为空,它会链接到

127.0.0.1:8887/5

任何帮助将不胜感激,这是一个错误吗?

4

2 回答 2

1

尝试使用这个:

$config['base_url'] = '/codeigniter-tests/index.php/pagination/index/';
于 2012-07-08T06:56:55.450 回答
1

我认为这$config['base_url']不支持不完整的 URL。尝试添加协议位或仅保留路径:

$config['base_url'] = 'http://127.0.0.1:8887/codeigniter-tests/index.php/pagination/index/';
$config['base_url'] = '/codeigniter-tests/index.php/pagination/index/';
于 2012-07-08T07:02:22.473 回答