0
votes

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

2 Answers

1
votes

I don't think that $config['base_url'] supports an incomplete URL. Try adding the protocol bit or leaving only the path:

$config['base_url'] = 'http://127.0.0.1:8887/codeigniter-tests/index.php/pagination/index/';
$config['base_url'] = '/codeigniter-tests/index.php/pagination/index/';
1
votes

Try to use this:

$config['base_url'] = '/codeigniter-tests/index.php/pagination/index/';