title: How do I display active record in codeigniter with multiple controllers?
body: <p>I am building my comment module and trying to get the active records to display on view. Seems simple however I have a lot going on and using a separate model and controller then what the view is being generated from. </p>
  
  <p>So I have a profile page ( where I'm trying to get the results to display )</p>
  
  <p>Controller:</p>
  
  <pre><code>public function profile() 
        {
              $this-&gt;load-&gt;helper('url'); //Include this line
              $this-&gt;load-&gt;helper('date');
              $this-&gt;load-&gt;library('session');
              $this-&gt;load-&gt;library('form_validation');
              $session_id = $this-&gt;session-&gt;userdata('id'); //Ensure that this session is valid
  
  
              //TRYING TO MAKE A VARIABLE WITHT THE $_GET VALUE
              $user_get = $this-&gt;uri-&gt;segment(3); // Modify this line
  
  
              // LOAD THE CORRECT USER
              $this-&gt;load-&gt;model('account_model');
              $user = $this-&gt;account_model-&gt;user($user_get); //(suggestion) you want to pass the id here to filter your record
  
              $data['user'] = $user;
              $data['session_id'] = $session_id;
  
  
  
  
              if($user_get != $user['id'] || !$user_get)
              {
                  $data['main_content'] = 'account/notfound';
                  $this-&gt;load-&gt;view('includes/templates/profile_template', $data);
              }
              else
              {
  
              if($user_get == $session_id) //Modify this line also
              {
                  $data['profile_icon'] = 'edit';
              }
              else
              {
                  $data['profile_icon'] = 'profile';
              }
              $sharpie = $this-&gt;sharpie($user);
              $data['sharpie'] = $sharpie;
              $data['main_content'] = 'account/profile';
              $this-&gt;load-&gt;view('includes/templates/profile_template', $data);
              }
  
          }
  </code></pre>
  
  <p>Now I have a new controller for my comments I'm trying to display:</p>
  
  <pre><code>public function airwave() {
          $this-&gt;load-&gt;helper('date');
          $this-&gt;load-&gt;library('session');
          $airwave_get = $this-&gt;uri-&gt;segment(3); 
          $this-&gt;load-&gt;model('community_model');
          $airwave = $this-&gt;coummunity_model-&gt;airwave($airwave_get); 
          $data['airwave'] = $airwave;
          $data['main_content'] = 'account/profile';
          $this-&gt;load-&gt;view('includes/templates/main_page_template', $data);
      }
  </code></pre>
  
  <p>with this model:</p>
  
  <pre><code>public function airwave($id=null) 
          {
              if(is_null($id)) {
                  $session = $this-&gt;session-&gt;userdata('is_logged_in');
                  $commenter_id = $this-&gt;session-&gt;userdata('id');
              }else{
                  $commenter_id = intval($id);
              }
  
              $query = $this-&gt;db-&gt;query("SELECT * FROM airwaves_comments WHERE from_id=$commenter_id");
              if($query-&gt;num_rows()==1)
              {
                 $data = $query-&gt;result_array();
                 return $data[0];
              //above returns the single row you need to the controller as an array.
              //to the $data['user'] variable.
  
              }
  
          }
  </code></pre>
  
  <p>and trying to display it on this view ( which is generated by the profile function )</p>
  
  <pre><code>&lt;div class="profile_airwave_comment_text"&gt;
      &lt;?php echo $airwave['comment'];?&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I just can't seem to get it to pass the array variable I've created properly to that view?</p>
  
  <p>thanks in advance.</p>