[eluser]weboap[/eluser]
i think your issue is you are using ->result() instead of ->row()
another way to do things.
Code:
//in model
// get department by id
function get_by_id($id){
$id=(int)$id;
$this->db->where('DepartmentId', $id);
$this->db->limit( 1 );
$query = $this->db->get('Department');
if( $query->num_rows() > 0 ) {
return $query->row();
} else {
return false;
}
}
in controller
Code:
$data['department'] = $this->department_model->get_by_id($id);
$this->load->view('dept_info', $data);
in 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>
<?php if(!$department){
echo 'department data not available';
}
else
{
?>
<h3 align="center">Business Impact Analysis(BIA) Questionnaire</h3>
<h5 align="center"><?php echo $department->DepartmentName; ?></h5>
<?php } ?>
</body>
</html>