title: Codeigniter: Pass data from model to controller but didn't get in the view file
body: <p>I was returning <code>query-&gt;result()</code> from my model to controller and in the controller I passed the <code>$data</code> to the view file but I am not getting any data in the view file.</p>
  
  <p>Here is the <strong>show_model.php</strong> file:</p>
  
  <pre><code>&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  
  class Show_model extends CI_Model {
  
      public function __construct()
      {
          parent::__construct();
          $this-&gt;load-&gt;database();
      }
      function get_post_data()
      {
          $query=$this-&gt;db-&gt;get('posts');
          return $query-&gt;result();
      }
  
  }
  </code></pre>
  
  <p>Here is the <strong>show.php</strong> file:</p>
  
  <pre><code>&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  
  class Show extends CI_controller {
  
      public function __construct()
      {
          parent::__construct();
      }
  
      function show_post_data(){
  
          $this-&gt;load-&gt;model("Show_model");
          $data['records'] = $this-&gt;Show_model-&gt;get_post_data();
          $this-&gt;load-&gt;view('list_view',$data);
      }
  }
  
  </code></pre>
  
  <p>Here is the <strong>show_list.php</strong> view file:</p>
  
  <pre><code>&lt;div&gt;
  &lt;?php echo "&lt;pre&gt;"; print_r($records); exit; ?&gt;
  &lt;/div&gt;
  </code></pre>