Please check my below code. This will help you.
Also cna you please put this code in View and share result.
php
var_dump($exam);
?>Also check your model code below.
php  
    class Fetch_data extends CI_Model  
    {  
        function __construct()  
        {   
            parent::__construct();  
        }  
        public function top_agriculture_exams($stream)
        {
            $this->db->select('exam_name');
            $this->db->from('all_exams_details');
            $this->db->where('exam_name',$stream);
            $this->db->order_by('exam_name');
            $this->db->limit('10');
            $query = $this->db->get(); 
            $result = $query->result_array();
            return $result;
        }
    } 
                 
                                             
                         
                        
manpreet![Tuteehub forum best answer]() Best Answer
                                                
                                                                                                        3 years ago
                                                    Best Answer
                                                
                                                                                                        3 years ago
                                                
                                            
controller: Test.php
view: header.php
model: Fetch_data.php
I am new in ci. In controller i.e. Test.php I am defining $stream='agriculture' and pass $stream variable to top_agriculture_exams model. Now, when I am fetching data on header.php file it show me a Message: Undefine variable: $exam I don't know why. So, how can I fix it ?please help me.
Thank You