title: CakePHP pagination not working beyond 1st page
body: <p>I have a view in my site that has two divs. one houses a search box and the other is where the result of the search is shown. by default, nothing is loaded on the result div. only when there is a search via post request, the result div is populated. However, this is causing problem with the pagination functionality as the second time the page loads, it doesnt have the data to go around with listing the rest of the results. How can i modify my controller/view to meet this need?</p>
  
  <p>My action in the controller:</p>
  
  <pre><code>public function search(){
          if($this-&gt;request-&gt;is('post')){
              if($this-&gt;request-&gt;data['User']['search']!=null){
                  $search_name=$this-&gt;request-&gt;data['User']['search'];
  
                  $this-&gt;Paginator-&gt;settings = array(
                      'conditions'=&gt;array('User.name LIKE'=&gt;'%'.$search_name.'%'),
                      'order' =&gt; array('User.datetime' =&gt; 'desc'),
                      'limit' =&gt; 10
                  );
  
                  $feed = $this-&gt;Paginator-&gt;paginate('User');
                  $this-&gt;set('search_result',$feed);
              }
  
              else{
                  $this-&gt;Session-&gt;setFlash(__("Cant make an empty search"));
                  return $this-&gt;redirect(array('action'=&gt;'search'));
              }
          }
      }
  </code></pre>
  
  <p>My View:</p>
  
  <pre><code>&lt;?php
  include 'header.ctp';
  
  echo '&lt;div id="feed"&gt;';
  echo $this-&gt;Form-&gt;create(null, array('url' =&gt; array('controller' =&gt; 'users', 'action' =&gt; 'search')));
  echo $this-&gt;Form-&gt;input('search');
  echo $this-&gt;Form-&gt;end('Search');
  echo 'search by name';
  echo '&lt;/div&gt;';
  
  if(isset($search_result)){
      echo '&lt;div id="tweet_records"&gt;';
  
      if(!empty($search_result)){
  
          foreach ($search_result as $user) : 
  
              $formatted_text;
              $latest_tweet_time;
              $formatted_time;
  
              if(!empty($user['Tweet'])){
                  $formatted_text=$this-&gt;Text-&gt;autoLinkUrls($user['Tweet']['0']['tweet']);
                  $latest_tweet_time=$user['Tweet']['0']['datetime'];
                  $formatted_time;
                  if(strlen($latest_tweet_time)!=0){
                      $formatted_time='Tweeted at '.$latest_tweet_time;
                  }
                  else{
                      $formatted_time='No tweets yet';    
                  }
              }
              else if(empty($user['Tweet'])){
                  $formatted_text='No tweets yet';
                  $formatted_time='';     
              }
              echo '&lt;table id="t01"&gt;';
              echo'&lt;tr&gt;';
  
              echo '&lt;td&gt;'.
                   $user['User']['name'].'@'.$this-&gt;HTML-&gt;link($user['User']['username'], array('controller'=&gt;'tweets','action'=&gt;'profile',$user['User']['id'])).'&lt;br&gt;'.$formatted_text.'&amp;nbsp;'.'&lt;br&gt;'.'&lt;font color="blue"&gt;'.$formatted_time.'&lt;/font&gt;';
  
                   echo '&lt;div id="delete"&gt;';
                   $selector='true';
  
                   foreach ($user['Follower'] as $follower) :
                      if($follower['follower_user_id']==AuthComponent::user('id')){
                          $selector='false';
                          echo $this-&gt;Form-&gt;postlink('Unfollow',array('controller'=&gt;'followers','action'=&gt;'unfollow',$user['User']['id']),array('confirm'=&gt;'Do you really want to unfollow this person?'));
                      }
                   endforeach;
  
                   if($selector=='true' &amp; $user['User']['id']!=AuthComponent::user('id')){
                      echo $this-&gt;Form-&gt;postlink('Follow',array('controller'=&gt;'followers','action'=&gt;'follow',$user['User']['id']));
                   }
                   echo '&lt;/div&gt;';
  
                   echo '&lt;/td&gt;';
  
  
              echo '&lt;/tr&gt;';
          endforeach;
  
          echo'&lt;/table&gt;';
  
  
          echo 'Pages: ';
  
          echo $this-&gt;Paginator-&gt;prev(
            ' &lt; ',
            array(),
            null,
            array('class' =&gt; 'prev disabled')
          );
  
          echo $this-&gt;Paginator-&gt;numbers();
  
          echo $this-&gt;Paginator-&gt;next(
              ' &gt; ' , 
              array(), 
              null, 
              array('class' =&gt; 'next disabled')
          );
  
      }
      else{
          echo '&lt;font color="red"&gt; No results found &lt;/font&gt;';
      }
      echo '&lt;/div&gt;';
  }
  </code></pre>