title: Displaying all the records from the database based on no-of views using codeigniter php
body: <p>Hi i am trying to fetch the records from database based on no-of-views of the page.But unable to fetch all the records getting only one record.here is my code.</p>
  
  <p><strong>Controller:</strong></p>
  
  <pre><code>function buzzling()
  {
      $data['records2'] = $this-&gt;blogs_model-&gt;get_all_buzzling();
      $data['mainpage'] = 'buzzling';
      $this-&gt;load-&gt;view('templates/template',$data);
  }
  </code></pre>
  
  <p><strong>Model:</strong></p>
  
  <pre><code>function get_all_buzzling()
  {
      $this-&gt;db-&gt;select('B.*');
      $this-&gt;db-&gt;from('blogs AS B');
      $this-&gt;db-&gt;where(array('B.status'=&gt;1));
      $this-&gt;db-&gt;order_by("ne_views", "asc");
      $q=$this-&gt;db-&gt;get();
      if($q-&gt;num_rows()&gt;0)
      {
          return $q-&gt;result();
      }
      else
      {
          return false;
      }
  }
  </code></pre>
  
  <p><strong>View:</strong></p>
  
  <pre><code>&lt;div class="right"&gt;
      &lt;?php if(isset($records2) &amp;&amp; is_array($records2)):?&gt;
          &lt;?php foreach ($records2 as $r):?&gt;
              &lt;h1 class="headline2"&gt;&lt;span class="headline"&gt;Buzzing&lt;/span&gt;&lt;/h1&gt;
              &lt;div class="clearfix float-my-children"&gt;
                  &lt;img src="&lt;?php echo base_url();?&gt;admin/images/blogimages/thumbs/&lt;?php echo $r-&gt;image_path;?&gt;" width=100&gt;
                  &lt;div class="blogclasstext1"&gt;&lt;?php echo $r-&gt;description;?&gt;&lt;/div&gt;
              &lt;/div&gt;
          &lt;?php endforeach ; endif;?&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>Sample database table</p>
  
  <pre><code>blog_id   image       description status ne_views
  1         image.png   description  1      3
  2         image.png   description  1      2
  3         image.png   description  1      4
  4         image.png   description  1      1
  </code></pre>