Issue
A PHP Error was encountered Severity: Notice
Message: Undefined variable: result
Filename: user/messages.php
Line Number: 87
Backtrace:
File: E:\xampp\htdocs\ci\application\views\user\messages.php Line: 87 Function: _error_handler
File: E:\xampp\htdocs\ci\application\controllers\users\Dashboard.php Line: 12 Function: view
File: E:\xampp\htdocs\ci\index.php Line: 315 Function: require_once
here is my code Controller
      <?php defined('BASEPATH') OR exit('No direct script access allowed');
        class Bills extends CI_Controller{
       function __construct(){
      parent::__construct();
     }
     public function bill(){
     $id = $this->session->userdata('email');
     $this->load->database();
     $this->load->helper(array('form', 'url', 'html'));
     $this->load->model('fuser/Bill');
     $data['result'] = $this->Bill->bills();
     $this->load->view('user/messages',$data);
      }
      }
      ?>
**Model**
      <?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->db->get('invoices'); 
       return $query->result();   
      }  
      }  
     ?> 
**View**
      <div class="billing_tabs_text_part">
                <?php foreach($result as $row){?>
                  <p><?php echo $row['book_id']; }?></p>
                </div>
Solution
i am not sure which section is your problem so i suggest something how to find error
public function bill()
{
    echo 'ok'; // check controller work
    $id = $this->session->userdata('email');
    $this->load->database();
    echo 'ok1';
    $this->load->helper(array('form', 'url', 'html'));
    echo 'ok2';
    /*$this->load->model('fuser/Bill');
    $data['result'] = $this->Bill->bills();
    $this->load->view('user/messages', $data);*/
}
if this is print ok, ok1 , ok2 then this is query problem , if no print ok,ok1 then this is not query problem
in this case try to find error, if other ok then must print ok
public function bill()
{
    echo 'ok';
    /*$id = $this->session->userdata('email');
    $this->load->database();
    $this->load->helper(array('form', 'url', 'html'));
    $this->load->model('fuser/Bill');
    $data['result'] = $this->Bill->bills();
    $this->load->view('user/messages', $data);*/
}
Answered By - Shafiqul Islam
 
 Posts
Posts
 
 
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.