title: Codeigniter Pagination issue
body: <p>I am trying to get the pagination to work with codeigniter. But am getting the following errors</p>
  
  <p>Severity: Notice
  Message: Undefined offset: 0
  Filename: controllers/group.php</p>
  
  <p>And</p>
  
  <p>Severity: Warning
  Message: Invalid argument supplied for foreach()
  Filename: views/group_list_view.php</p>
  
  <p>Following is the code of my Model</p>
  
  <pre><code>public function get_list($userid)  
  {  
      $this-&gt;load-&gt;library('pagination');
  
      $config['base_url'] = 'http://localhost/portal/index.php/group/index';
      $config['total_rows'] =$this-&gt;db-&gt;where('UserId',$userid)-&gt;get('group')-&gt;num_rows();
      $config['per_page'] = 10;
      $config['num_links'] = 10;
  
      $this-&gt;pagination-&gt;initialize($config);
  
      $query['groups'] = $this-&gt;db-&gt;get('group', $config['per_page'], $this-&gt;uri-&gt;segment(3));
      return   $query;
  
  }  
  </code></pre>
  
  <p>Here is the code for my controller</p>
  
  <pre><code>class Group extends CI_Controller {
  
   public function __constructor()
   {
      session_start();
      parent::__constructor();
   }
  
  
   public function index()
   {
       if(!$this-&gt;session-&gt;userdata('userid'))
          redirect('login');
  
       $this-&gt;load-&gt;model('group_model');
       $result = $this-&gt;group_model-&gt;get_list($this-&gt;session-&gt;userdata('$userid'));
  
       //neither this works
       data['groups'] = $result;
       //nor this
       $data['groups'] = $result[0];
  
       $this-&gt;load-&gt;view('group_list_view', $data);
   }
  }
  </code></pre>
  
  <p>And this the code in view</p>
  
  <pre><code>foreach($groups as $group){
                          echo $group-&gt;GroupId;
                      }
  </code></pre>
  
  <p>Can anyone please guide me where am i doing it worng. Apparently no one else seems to have encountered any such problem. I followed the tutorial from <a href="http://net.tutsplus.com/tutorials/php/codeigniter-from-scratch-day-7-pagination/" rel="nofollow">net.tutsplus</a> ditto but still facing the same issue. Please note i am new to PHP to be gentel :)</p>