Welcome Guest, Not a member yet? Register   Sign In
having issues with Error: Trying to get Property of Non Object. Help!!!
#3

[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">
&lt;html&gt;
&lt;head&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;?php if(!$department){
  
echo 'department data not available';
}
else
{
?&gt;



<h3 align="center">Business Impact Analysis(BIA) Questionnaire</h3>
<h5 align="center">&lt;?php echo $department->DepartmentName; ?&gt;</h5>
















&lt;?php } ?&gt;


&lt;/body&gt;
&lt;/html&gt;






Messages In This Thread
having issues with Error: Trying to get Property of Non Object. Help!!! - by El Forum - 05-30-2012, 01:40 PM



Theme © iAndrew 2016 - Forum software by © MyBB