title: Codeigniter-returning value to output in table with foreach
body: <p>I am using Codeigniter, and I want to return some information for an advisor. For some reason, the model isn't returning anything from the database (I'm assuming since I placed text throughout the table in view and nothing came up). The query calls information from two different tables, and I used the query directly in the database to make sure it works.</p>
  
  <p>At this point, I'm sure that it is something small that I'm missing. Any insight is appreciated. </p>
  
  <p><strong>Model</strong></p>
  
  <pre><code>function profileInfo($user_id, $user_type)
  {
      if($user_type == 'advisor')
      {
          $this-&gt;db-&gt;select('user_fullname, CWID, user_name, user_email, user_phone, major, office_loc');
          $this-&gt;db-&gt;from('users, advisor');
          $this-&gt;db-&gt;where('users.user_id', $user_id);
          $this-&gt;db-&gt;where('users.user_id = advisor.user_id');
  
          $query = $this-&gt;db-&gt;get();
          return $query-&gt;result();
      }
  
  
      elseif($user_type == 'advisee')
      {
          $this-&gt;db-&gt;select('user_fullname, CWID, user_name, user_email, user_phone, major, classification');
          $this-&gt;db-&gt;from('users, advisee');
          $this-&gt;db-&gt;where('users.user_id', $user_id);
          $this-&gt;db-&gt;where('users.user_id = advisee.user_id');
  
          $query = $this-&gt;db-&gt;get();
          return $query-&gt;result();
      }
  
  
      else
      {
          $this-&gt;db-&gt;select('user_fullname, CWID, user_name, user_email, user_phone');
          $this-&gt;db-&gt;from('users');
          $this-&gt;db-&gt;where('user_id', $user_id);
  
          $query = $this-&gt;db-&gt;get();
          return $query-&gt;result();
      }
  
  }
  </code></pre>
  
  <p><strong>Controller</strong> </p>
  
  <pre><code>    function profilePage()
      {
          $CWID = $this-&gt;session-&gt;userdata('id');
          $userType = $this-&gt;session-&gt;userdata('user_type');
          $data = array('view' =&gt; 'viewProfile', 'userid' =&gt; $CWID, 'usertype' =&gt; $userType, 'user_info' =&gt; $this-&gt;Users_model-&gt;profileInfo($CWID, $userType));
          $this-&gt;load-&gt;view('admin', $data);
      }
  </code></pre>
  
  <p><strong>View</strong> </p>
  
  <pre><code>    &lt;?php if($usertype =='advisor'): ?&gt;
      &lt;table&gt;
          &lt;?php foreach ($user_info as $row): ?&gt;
          &lt;tr&gt;    
              &lt;th&gt;Name:  &lt;/th&gt;
              &lt;td&gt;&lt;?php echo $row-&gt;user_fullname?&gt;&lt;/td&gt;
          &lt;/tr&gt;       
          &lt;tr&gt;
              &lt;th&gt;CWID: &lt;/th&gt;
              &lt;td&gt;&lt;?php echo $row-&gt;CWID ?&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;th&gt;User Name: &lt;/th&gt;
              &lt;td&gt;&lt;?php echo $row-&gt;user_name ?&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;th&gt;Email: &lt;/th&gt;
              &lt;td&gt;&lt;?php echo $row-&gt;user_email ?&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;th&gt;Phone: &lt;/th&gt;
              &lt;td&gt;&lt;?php echo $row-&gt;user_phone ?&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;th&gt;Major: &lt;/th&gt;
              &lt;td&gt;&lt;?php echo $row-&gt;major ?&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;th&gt;Office Location: &lt;/th&gt;
              &lt;td&gt;&lt;?php echo $row-&gt;office_loc ?&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;?php endforeach ?&gt;
      &lt;/table&gt;    
  
  &lt;!--Provides view for a user that is an advisee--&gt;
  &lt;?php elseif($usertype =='advisee'): ?&gt;
      &lt;table&gt; 
      &lt;?php foreach ($user_info as $row): ?&gt;
          &lt;tr&gt;
              &lt;th&gt;Name: &lt;/th&gt;
              &lt;td&gt;&lt;?php echo $row-&gt;user_fullname ?&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;th&gt;CWID: &lt;/th&gt;
              &lt;td&gt;&lt;?php echo $row-&gt;CWID ?&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;th&gt;User Name: &lt;/th&gt;
              &lt;td&gt;&lt;?php echo $row-&gt;user_name ?&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;th&gt;Email: &lt;/th&gt;
              &lt;td&gt;&lt;?php echo $row-&gt;user_email ?&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;th&gt;Phone: &lt;/th&gt;
              &lt;td&gt;&lt;?php echo $row-&gt;user_phone ?&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;th&gt;Major: &lt;/th&gt;
              &lt;td&gt;&lt;?php echo $row-&gt;major ?&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;th&gt;Classification: &lt;/th&gt;
              &lt;td&gt;&lt;?php echo $row-&gt;classification ?&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;?php endforeach ?&gt;
      &lt;/table&gt;
      &lt;!--Provides view for all other user types--&gt;
  &lt;?php else: ?&gt;
      &lt;table&gt; 
      &lt;?php foreach ($user_info as $row): ?&gt;
          &lt;tr&gt;
              &lt;th&gt;Name: &lt;/th&gt;
              &lt;td&gt;&lt;?php echo $row-&gt;user_fullname ?&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;th&gt;CWID: &lt;/th&gt;
              &lt;td&gt;&lt;?php echo $row-&gt;CWID ?&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;th&gt;User Name: &lt;/th&gt;
              &lt;td&gt;&lt;?php echo $row-&gt;user_name ?&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;th&gt;Email: &lt;/th&gt;
              &lt;td&gt;&lt;?php echo $row-&gt;user_email ?&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;th&gt;Phone: &lt;/th&gt;
              &lt;td&gt;&lt;?php echo $row-&gt;user_phone ?&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;?php endforeach ?&gt;
      &lt;/table&gt;
  &lt;?php endif ?&gt;  
  </code></pre>