title: A multilevel list with CodeIgniter
body: <p>I'm newly working with CodeIgniter and PHP. I'm trying to do a simple task that is to show a multilevel menu. Let's say I have a student and status table. I want to show which students are under which status(senior, junior etc.). But I'm getting this error:</p>
  
  <pre><code>A PHP Error was encountered
  
  Severity: Notice
  
  Message: Trying to get property of non-object
  
  Filename: views/sview.php
  
  Line Number: 31
  </code></pre>
  
  <p>At line 31 i have </p>
  
  <pre><code>&lt;?php echo $status-&gt;statusname;?&gt;
  </code></pre>
  
  <p>The controller:</p>
  
  <pre><code>// ....
  $data['status'] = $this-&gt;status_model-&gt;get_students();
  $this-&gt;load-&gt;view('sview', $data);
  </code></pre>
  
  <p>The model:</p>
  
  <pre><code>function get_students(){
  
      $s = $this-&gt;db-&gt;get('status');
  
      foreach ($s-&gt;result() as $status){
  
          $students = $this-&gt;db-&gt;get_where('student', array('status_id'=&gt;$status-&gt;id));
          $status-&gt;students = students-&gt;result();
      }
  
      return $s;
  }
  </code></pre>
  
  <p>view:</p>
  
  <pre><code>&lt;?php foreach($s as $status):?&gt;
      &lt;h4&gt;&lt;?php echo $status-&gt;statusname;?&gt;&lt;/h4&gt;
      &lt;?php foreach($status-&gt;student as $student):?&gt;
          &lt;?php echo $student-&gt;studentname; ?&gt;
      &lt;?php endforeach;?&gt;
  &lt;?php endforeach;?&gt;
  </code></pre>