CodeIgniter Forums
Pagination once more - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived General Discussion (
+--- Thread: Pagination once more (/thread-5018.html)

Pagination once more - El Forum - 12-31-2007

[eluser][email protected]_[/eluser]

I'm sorry to bother you with a very discussed topic but, I still can't make pagination to work on my website. Here's the code:
function index()
    $config['base_url'] = 'http://localhost/website/index.php/see/';
    $config['total_rows'] = $this->db->count_all('projects');
    $config['per_page'] = 4;
    $config['uri_segment'] = 2;
    $num     = $config['per_page'];
    $offset = $this->uri->segment(2);
    $data['query']= $this->db->get('projects', $num, $offset);

<?php foreach($query->result() as $row): ?>
<h3>&lt;?php echo $row->title; ?&gt;</h3>
<p>&lt;?php echo $row->description; ?&gt;</p>

<hr />
&lt;?php endforeach; ?&gt;
&lt;?php echo $links; ?&gt;
When i load index.php/see , I get the correct 4 results per page, the correct numbers of links considering the total rows, but when I click a link, there's a 404 message.
The links don't have correct paths. They change along with the $config['per_page']. All the necessary libraryes and helpers are loaded. What could be the problem?

Pagination once more - El Forum - 12-31-2007

[eluser]Craig A Rodway[/eluser]
What difference does it make if you change the base_url variable to site_url('see/index'); ?

Pagination once more - El Forum - 12-31-2007

[eluser]Mark van der Walle[/eluser]
Indeed, CI will create the following urls:

When you click on that it will try to call a controller see with the function 0,4,8 etc. These dont exist (and could not for that matter). Either use some URI routing if you do not want to show the index or add the index to the baseurl

Pagination once more - El Forum - 12-31-2007

[eluser][email protected]_[/eluser]
Thanks for the help! If I change the base_url variable with site_url(’see/index’), I won't get a 404 but the page won't change neither. How can I create URI routing to solve this?

Nevermind. It works now with site_url(’see/index’) and the URI segment is 3.
Thank you! Smile