Note that there are some explanatory texts on larger screens.

plurals
  1. POCodeIgniter Pagination, possible routing issue?
    primarykey
    data
    text
    <p>I'm trying to learn CodeIgniter and I'm having trouble with the pagination. I'm a complete newbie so I apologise if I've missed anything.</p> <p>The pagination displays on my views fine, generates everything it should, but the pages give me a 404. I suspect it might have something to do with the routes or the uri_segment (though I've changed it to a whole bunch of numbers and nothing did the trick), but I'm not sure.</p> <p>The URLs each page generates are /music3/music/20, /music3/music/40, etc.</p> <p>Let me know if you need anything I haven't included.</p> <p>Controller: </p> <pre><code>$config['base_url'] = 'http://moefoster.com/music3/music/'; $config['total_rows'] = $this-&gt;db-&gt;count_all('Music'); $config['per_page'] = '20'; $config['num_links'] = '5'; $config['uri_segment'] = '2'; $this-&gt;pagination-&gt;initialize($config); $data['music'] = $this-&gt;music_model-&gt;get_music($config['per_page'], $config['uri_segment']); </code></pre> <p>Model: </p> <pre><code>public function get_music($num = 20, $offset = 0, $slug = FALSE) { if ($slug === FALSE) { return $this-&gt;db-&gt;select('*')-&gt;from('Music')-&gt;limit($num, $offset)-&gt;order_by('Release', 'desc')-&gt;get()-&gt;result_array(); } $query = $this-&gt;db-&gt;get_where('Music', $num, $offset, array('Track' =&gt; $slug)); return $query-&gt;row_array(); } </code></pre> <p>Routes:</p> <pre><code>$route['music'] = 'music'; $route['default_controller'] = "music"; $route['(:any)'] = 'pages/view/$1'; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload