title: Adding row_array to result_array foreach loop with codeigniter?
body: <p>I currently have a function on a web app which I'm building where a jobseeker can view the jobs they have applied for, very simple.</p>
  
  <p>When they "apply" this application is stored in the database table 'applications' with a 'job_id' column which stores the 'id' of the job from the 'jobs' database table.</p>
  
  <p>At the moment I am able to pull each application the said jobseeker has made.</p>
  
  <p>Though, I am unable to loop through each application and find the job which corresponds to that application and then add the row_array() to larger array which I will then output the jobs with a foreach loop.</p>
  
  <p>Essentially I am asking how do I add an array to an array and then output the full array?</p>
  
  <p><strong>appliedfor.php</strong> (CONTROLLER)</p>
  
  <pre><code>$applications_query = $this-&gt;db-&gt;get_where(
      'applications', array('jobseeker_profile_id' =&gt; $user['id'])
  );
  $applications = $applications_query-&gt;result_array();
  
  $data[] = array();
  
  foreach ($applications as $application) {
      $job_id = $application['job_id'];
      $data['job'] = $this-&gt;db-&gt;get_where('jobs', array('id' =&gt; $job_id))-&gt;row_array();
      $data['jobs'] .= $data['job'];
  }
  
  $data['jobs'];
  
  $this-&gt;load-&gt;view('header');
  $this-&gt;load-&gt;view('appliedfor', $data); 
  </code></pre>
  
  <p><strong>appliedfor.php</strong> (VIEW)</p>
  
  <pre><code>foreach ($jobs as $job) {
      $single_job_id = $job['id'];
  
      echo "&lt;br&gt;";
      echo form_open('job/view' . '" id="eachJob');
  
      echo "&lt;div id=\"leftContain\" class=\"floatLeft\"&gt;";
      echo "&lt;h4 class=\"green\"&gt;" . $job['role'] . "&lt;/h4&gt;";
      echo "&lt;div class=\"italic\"&gt;&lt;div class=\"blue floatLeft\"&gt;" . $job['company']
          . " &amp;nbsp; &lt;/div&gt;&lt;div class=\"floatLeft\"&gt;in&lt;/div&gt;&lt;div class=\"blue floatLeft\"&gt; &amp;nbsp; "
          . $job['location'] . "&lt;/div&gt;&lt;/div&gt;&lt;br&gt;&lt;br&gt;";
      echo "&lt;/div&gt;";
  
      echo "&lt;div id=\"rightContain\" class=\"floatLeft\"&gt;";
      echo "&lt;input type=\"hidden\" name=\"job_id\" value=\"" . $single_job_id . "\"&gt;";
      echo form_submit('submit' . '" class="jobButton floatRight"', 'View Job');
      echo "&lt;/div&gt;";
  
      echo form_close();
  }
  </code></pre>
  
  <p>I am currently getting 2 errors: Undefined index: jobs and the error is on this line apparently <code>$data['jobs']</code> in the controller within the foreach.</p>
  
  <p>The other error is the foreach within the view file but that is basically triggered by the first error.</p>
  
  <p>Thanks for your help.</p>