I'm working on a view that shows me the data from the database.
but the result is
Severity: Notice
Message: Undefined variable: data
Filename: mentee/index.php
UserModel.php
<?php
class UserModel extends CI_Model{
public function __construct(){
parent::__construct();
}
public function userProfile($nim){
$this->db->where('userNIM',$nim);
$query= $this->db->get('msuser');
return $query->result();
}
}
MainController.php
public function indexMentee()
{
$this->load->model('UserModel');
$userID=$this->session->userdata("userNIM");
$data['data'] = $this->UserModel->userProfile($userID);
$this->load->view('mentee/index', array('data' => $data));
}
View
<?php
die(var_dump($data));
if(is_array($data)){
foreach ($data as $profile):
?>
<div class="header-content">
<div class="header-content-inner">
<h1>Learning Center</h1>
<hr>
<h3> Welcome,<?php echo $profile->userName ?></h3>
</div>
</div>
<?php
endforeach;
}
?>
Please help me..Thanks a lot!