title: A PHP Error was encountered Severity: Notice Message: Undefined variable: result
body: <blockquote>
    <p>A PHP Error was encountered Severity: Notice</p>
    
    <p>Message: Undefined variable: result</p>
    
    <p>Filename: user/messages.php</p>
    
    <p>Line Number: 87</p>
    
    <p>Backtrace:</p>
    
    <p>File: E:\xampp\htdocs\ci\application\views\user\messages.php Line: 87
    Function: _error_handler</p>
    
    <p>File: E:\xampp\htdocs\ci\application\controllers\users\Dashboard.php
    Line: 12 Function: view</p>
    
    <p>File: E:\xampp\htdocs\ci\index.php Line: 315 Function: require_once</p>
  </blockquote>
  
  <p><strong>here is my code</strong>
  <strong>Controller</strong></p>
  
  <pre><code>      &lt;?php defined('BASEPATH') OR exit('No direct script access allowed');
          class Bills extends CI_Controller{
         function __construct(){
        parent::__construct();
       }
  
       public function bill(){
       $id = $this-&gt;session-&gt;userdata('email');
       $this-&gt;load-&gt;database();
       $this-&gt;load-&gt;helper(array('form', 'url', 'html'));
       $this-&gt;load-&gt;model('fuser/Bill');
       $data['result'] = $this-&gt;Bill-&gt;bills();
       $this-&gt;load-&gt;view('user/messages',$data);
        }
        }
        ?&gt;
  
  **Model**
  
        &lt;?php  
       class Bill extends CI_Model  
       {  
        function __construct()  
        {  
           // Call the Model constructor  
           parent::__construct();  
        }  
        //we will use the select function  
        public function bills($id)  
        {  
           //data is retrive from this query  
  
       $query = $this-&gt;db-&gt;get('invoices'); 
         return $query-&gt;result();   
        }  
  
  
  
  
  
        }  
       ?&gt; 
  
  **View**
        &lt;div class="billing_tabs_text_part"&gt;
                  &lt;?php foreach($result as $row){?&gt;
                    &lt;p&gt;&lt;?php echo $row['book_id']; }?&gt;&lt;/p&gt;
                  &lt;/div&gt;
  </code></pre>