Reputation: 1
I don't know where's the error but it always shows undefined variable. Here's my code:
Model
class profile_info extends CI_Model {
public function get_profile_information($id)
{
$query = $this->db->get_where('accountSystem', array('id' => $id));
return $query->row();
}
}
Controller
class home extends CI_Controller {
public function display_name()
{
$this->load->model('profile_info');
$data['profile'] = $this->profile_info->get_profile_information($id);
$this->load->view('account_info_view', $data);
}
}
View
<!DOCTYPE html>
<html>
<head>
<title>Account Information</title>
</head>
<body>
<h1><?php echo $profile->name; ?></h1>
</body>
</html>
Thank you!
Upvotes: 0
Views: 375
Reputation: 135
In the display_name()
function I didn't see any parameter being passed (in this case, it's $id
).
So eventually the $id
variable $this->profile_info->get_profile_information($id)
will appears undefined. Give display_name()
function a parameter.
Ex: display_name($id) {...}
.
Upvotes: 1