duanrong6802 2012-07-08 06:51
浏览 116
已采纳

codeigniter分页create_links()

The problem is that in pagination, i haven't got the database things showing up yet, but the problem isn't in that.

The problem is that I've got the page links showing up, but when I click the link to page 2, it goes to

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

As you can see, the link is basically repeated twice, now if I click 1 while on page 2, it takes me to

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/pagination/index/

So as you can see, now it's written thrice, if I click 2 on this page it appends the url again and takes me there :/

Now I would like to ask WHY IS THIS happening???

Heres the code:_

Controller(pagination.php)

class Pagination extends 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);


}

}

Here's the view(pagination_view.php):_

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

Just a bit of extra info, if I set $config['base_url'] to nothing, it links to

127.0.0.1:8887/5

Any help would be appreciated, is this a bug?

  • 写回答

2条回答 默认 最新

  • doudu7626 2012-07-08 06:56
    关注

    Try to use this:

    $config['base_url'] = '/codeigniter-tests/index.php/pagination/index/';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab