[eluser]reghan[/eluser]
Hello I am getting the error trying to get property of non object.
here is my code
Model:
Code:
<?php
class Department_model extends CI_Model {
public function __construct()
{
$this->load->database();
}
function depart_table_list() //list the departments names
{
$this->db->order_by('DepartmentName', 'asc');
return $this->db->get('department');
}
// get department by id
function get_by_id($id){
$this->db->where('DepartmentId', $id);
return $this->db->get('Department');
}
}
Controller function:
Code:
function get_dept_info()
{
$id = $this->uri->segment(3);
$dept_info = $this->department_model->get_by_id($id);
$data['department'] = $dept_info->result();
$this->load->view('dept_info', $data);
}
view:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
</head>
<body>
<h3 align="center">Business Impact Analysis(BIA) Questionnaire</h3>
<h5 align="center"><?php echo $department->DepartmentName; ?></h5>
</body>
</html>
I basically am just looking to print out the department name based on the id selected. I feel like this should be simple and am not really sure where I am going wrong.
Thanks to all who reply!!