title: Codeginiter pagination adding extra results per page
body: <p>I have a codigniter application running which I have added pagination to the the results page. I have an issue in that the page gives the first 5 results but then subsequent pages add 5 more results on each page eventually giving a page full of results.</p>
  <p>This is my controller code for the pagination</p>
  <pre><code>$paginatedFiles = array();
      if($ert&lt;count($result)){
      $paginatedFiles = array_slice($result, $ert, $ert + 5, true);
      }else{
          $paginatedFiles = array_slice($result, $ert, count($result), true);
      }
      
      $config[&quot;base_url&quot;] = base_url() . &quot;properties/index&quot;;
      $config[&quot;total_rows&quot;] = count($result);
      $config[&quot;per_page&quot;] = 5;
      $config[&quot;uri_segment&quot;] = 3;
      $config['use_page_numbers'] = TRUE;
  
      $this-&gt;pagination-&gt;initialize($config);
  
      $page = ($this-&gt;uri-&gt;segment(3)) ? $this-&gt;uri-&gt;segment(3) : 0;
      
      $this-&gt;load-&gt;view('properties',[
                  'address_result'=&gt;$paginatedFiles,
                  'keyword'=&gt;$sel_keyword,
                  'property_type'=&gt;$this-&gt;input-&gt;post('property_type'),
                  'sqft' =&gt; $this-&gt;input-&gt;post('sqft'),
                  'acres' =&gt; $this-&gt;input-&gt;post('acres'),
                  'frlh' =&gt; $this-&gt;input-&gt;post('frlh'),
                  'links'=&gt;$this-&gt;pagination-&gt;create_links()
                  
                  ]);
  </code></pre>
  <p>I think it is this line but I cannot work out how to solve it.</p>
  <pre><code>$paginatedFiles = array_slice($result, $ert, $ert + 5, true);
  </code></pre>