Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You have to set offset and limit when you query from the database to make pagination work.</p> <p>your get_search model should be like this</p> <pre><code>function get_search($match, $match2, $limit, $offset){ $this-&gt;db-&gt;limit($limit, $offset); /*Rest of the code*/ } </code></pre> <p>your current query becomes</p> <pre><code>$data['query'] = $this-&gt;bedrijven_model-&gt;get_search($match, $match2, 2147483647, 0); /*large number as limit to retrieve all the rows*/ </code></pre> <p>You need to query another time with offset and limit like this</p> <pre><code>$data['query_curr'] = $this-&gt;bedrijven_model-&gt;get_search($match, $match2, $config['per_page'], $this-&gt;uri-&gt;segment(3) ); </code></pre> <p>Here, $config['per_page'] is the limit and the offset is taken from the url segment( You have to initialize url helper. You need to use this <code>query_curr</code> variable in the view. This is the way to use pagination and correct number of rows will be shown.</p> <p>Last thing, you don't have to send create_links() as variable in the view. You can use that directly in the view.</p> <p><strong>UPDATE:</strong></p> <p>Change your <code>searchresult</code> function to this</p> <pre><code>function searchresults() { $this-&gt;breadcrumbs-&gt;page = array('link'=&gt; base_url().'home/search' ,'title' =&gt; 'Bedrijven Zoeken' ); $this-&gt;breadcrumbs-&gt;method = array('link'=&gt; base_url().'home/searchresults' ,'title' =&gt; 'Zoekresultaten' ); $data['breadcrumbs'] = $this-&gt;breadcrumbs-&gt;get(); $match = $this-&gt;input-&gt;post('search'); if(strlen($this-&gt;input-&gt;post('cookie')) &gt; 0){ $match2 = $this-&gt;input-&gt;post('cookie'); } else{ $match2 = '9101'; } $data['query'] = $this-&gt;bedrijven_model-&gt;get_search($match, $match2, 2147483647, 0); $this-&gt;load-&gt;library('pagination'); $config['base_url'] = base_url().'home/searchresults/'; $config['total_rows'] = count($data['query']); $config['per_page'] = 4; $this-&gt;pagination-&gt;initialize($config); $data['links'] = $this-&gt;pagination-&gt;create_links(); //$data['query'] = $this-&gt;bedrijven_model-&gt;get_search($match, $match2, 2147483647, 0); /*large number as limit to retrieve all the rows*/ $data['query_curr'] = $this-&gt;bedrijven_model-&gt;get_search($match, $match2, $config['per_page'], $this-&gt;uri-&gt;segment(3) ); $this-&gt;load-&gt;view('views/header'); $this-&gt;load-&gt;view('views/searchresults', $data); $this-&gt;load-&gt;view('views/footer'); } </code></pre>
 

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