title: how to return data from model to controler and controler to views in codeigniter
body: <p>i am using codeigniter. i have a table to be displayed in a view file. so i have a model where i fire a query to get the data from table.</p>
  
  <pre><code>function my_active_requests()
      {
          $user_id =  $this-&gt;session-&gt;userdata('user_id');
          $this-&gt;db-&gt;select('id,request_date,required_by_date');
              $this-&gt;db-&gt;where('requested_by',$user_id);
              return $this-&gt;db-&gt;get('requests');
              ///also tried with 
              //$query = $this-&gt;db-&gt;get('requests');
          ///$number_of_rows = $query-&gt;num_rows;
              //return $query;
              //return $number_of_rows;
              //but no result
       }
  </code></pre>
  
  <p>this is the model function. </p>
  
  <p>this is my controller</p>
  
  <pre><code>function my_active_req()
          {
  
              $this-&gt;bloodline_model-&gt;my_active_requests();
                      //also tried without this// 
                      $query = $this-&gt;db-&gt;get('requests');
                      //and this//
              $number_of_rows = $query-&gt;num_rows;
              $this-&gt;load-&gt;view('my_active_req');
          }   
  </code></pre>
  
  <p>and this is my view</p>
  
  <pre><code>&lt;?php foreach ($query-&gt;result() as $row) { ?&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;?php echo $row-&gt;id; ?&gt;&lt;/td&gt;
              &lt;td&gt;&lt;?php echo $row-&gt;request_date; ?&gt;&lt;/td&gt;
              &lt;td&gt;&lt;?php echo $row-&gt;required_by_date; } ?&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  </code></pre>
  
  <p>but the error is undefined variable $query. 
  i think , i am not able to return the $query and other data from my model to controller and controller to my view.
  Please provide me with the solution.
           `</p>