Note that there are some explanatory texts on larger screens.

plurals
  1. PORecords not limited on searchpage using codeigniter pagination
    text
    copied!<p><strong>Situation</strong></p> <p>I have a searchform which redirects to a searchresults page in which I want to implement Codeigniter Pagination. My limit is not working. So all the results are shown instead of my <code>$limit = 4;</code></p> <p>Here is my controller code:</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); $limit = 4; $this-&gt;load-&gt;library('pagination'); $config['base_url'] = base_url().'home/searchresults/'; $config['total_rows'] = count($data['query']); $config['per_page'] = $limit; $config['uri_segment'] = 3; $this-&gt;pagination-&gt;initialize($config); $data['links'] = $this-&gt;pagination-&gt;create_links(); $this-&gt;load-&gt;view('views/header'); $this-&gt;load-&gt;view('views/searchresults', $data); $this-&gt;load-&gt;view('views/footer'); } </code></pre> <p><strong>Question</strong></p> <p>What could be the problem? Am I missing something?</p> <hr> <h2>EDIT</h2> <p>I still can't get it to work. this is what i have so far.</p> <p>Controller:</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'; } $this-&gt;load-&gt;library('pagination'); $config['base_url'] = base_url().'home/searchresults/'; $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> <p>Model:</p> <pre><code>function get_search($match, $match2, $limit, $offset) { $this-&gt;db-&gt;limit($limit, $offset); //rest of the code } </code></pre> <p>My views:</p> <pre><code> &lt;?php foreach($query_curr as $item):?&gt; &lt;br/&gt; &lt;div class="logo1"&gt; &lt;a href="&lt;?php echo base_url()?&gt;bedrijven/&lt;?= $item['idbedrijven'] ?&gt;"&gt;&lt;img src="http://i.ebayimg.com/t/Aluminum-Body-Violin-or-Cello-Makers-Compass-Draw-Shave-Plane-Good-Shape-/00/s/NDYwWDU1MQ==/$(KGrHqJ,!hYF!sl)RwymBQiLq5Cn4Q~~60_35.JPG"&gt;&lt;/a&gt; &lt;/div&gt; &lt;a href="&lt;?php echo base_url()?&gt;bedrijven/&lt;?= $item['idbedrijven'] ?&gt;"&gt;&lt;h3&gt;&lt;?= $item['Bedrijfsnaam'] ?&gt;&lt;/h3&gt;&lt;/a&gt; &lt;p&gt; &lt;b&gt;Categorie:&lt;/b&gt; &lt;?php echo "" . $item['Categorie'] . ", &amp;nbsp;" ; ?&gt; &lt;/p&gt; &lt;small&gt; &lt;p&gt;&lt;b&gt;&lt;?php echo $item['Email'] ?&gt;&lt;/b&gt;&lt;/p&gt; &lt;p&gt;&lt;b&gt;Postcode:&lt;/b&gt; &lt;?php echo $item['Postcode'] ?&gt;&lt;/p&gt; &lt;p&gt;&lt;b&gt;Plaats:&lt;/b&gt; &lt;?php echo $item['Plaats'] ?&gt;&lt;/p&gt; &lt;p&gt;&lt;b&gt;Tags:&lt;/b&gt;&lt;/p&gt; &lt;p&gt;&lt;?php echo $item['Profiel'] ?&gt;&lt;/p&gt; &lt;/small&gt; &lt;br/&gt;&lt;hr/&gt; &lt;?php endforeach;?&gt; &lt;br/&gt; &lt;?= $this-&gt;pagination-&gt;create_links(); ?&gt; &lt;br /&gt; &lt;br /&gt; </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