{"id":3329,"date":"2014-03-23T02:20:48","date_gmt":"2014-03-23T02:20:48","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/23\/adding-row_array-to-result_array-foreach-loop-with-codeigniter-collection-of-common-programming-errors-2\/"},"modified":"2014-03-23T02:20:48","modified_gmt":"2014-03-23T02:20:48","slug":"adding-row_array-to-result_array-foreach-loop-with-codeigniter-collection-of-common-programming-errors-2","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/23\/adding-row_array-to-result_array-foreach-loop-with-codeigniter-collection-of-common-programming-errors-2\/","title":{"rendered":"Adding row_array to result_array foreach loop with codeigniter?-Collection of common programming errors"},"content":{"rendered":"<p>I currently have a function on a web app which I&#8217;m building where a jobseeker can view the jobs they have applied for, very simple.<\/p>\n<p>When they &#8220;apply&#8221; this application is stored in the database table &#8216;applications&#8217; with a &#8216;job_id&#8217; column which stores the &#8216;id&#8217; of the job from the &#8216;jobs&#8217; database table.<\/p>\n<p>At the moment I am able to pull each application the said jobseeker has made.<\/p>\n<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>\n<p>Essentially I am asking how do I add an array to an array and then output the full array?<\/p>\n<p><strong>appliedfor.php<\/strong> (CONTROLLER)<\/p>\n<pre><code>$applications_query = $this-&gt;db-&gt;get_where(\n    'applications', array('jobseeker_profile_id' =&gt; $user['id'])\n);\n$applications = $applications_query-&gt;result_array();\n\n$data[] = array();\n\nforeach ($applications as $application) {\n    $job_id = $application['job_id'];\n    $data['job'] = $this-&gt;db-&gt;get_where('jobs', array('id' =&gt; $job_id))-&gt;row_array();\n    $data['jobs'] .= $data['job'];\n}\n\n$data['jobs'];\n\n$this-&gt;load-&gt;view('header');\n$this-&gt;load-&gt;view('appliedfor', $data); \n<\/code><\/pre>\n<p><strong>appliedfor.php<\/strong> (VIEW)<\/p>\n<pre><code>foreach ($jobs as $job) {\n    $single_job_id = $job['id'];\n\n    echo \"<br \/>\";\n    echo form_open('job\/view' . '\" id=\"eachJob');\n\n    echo \"\";\n    echo \"<\/code><\/pre>\n<h4 class=\"\\&quot;green\\&quot;\"><code>\" . $job['role'] . \"<\/code><\/h4>\n<pre>\";\n    echo \"\" . $job['company']\n        . \"   in   \"\n        . $job['location'] . \"<br \/><br \/>\";\n    echo \"\";\n\n    echo \"\";\n    echo \"\";\n    echo form_submit('submit' . '\" class=\"jobButton floatRight\"', 'View Job');\n    echo \"\";\n\n    echo form_close();\n}\n<\/pre>\n<p><code>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.<\/code><\/p>\n<p>The other error is the foreach within the view file but that is basically triggered by the first error.<\/p>\n<p>Thanks for your help.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I currently have a function on a web app which I&#8217;m building where a jobseeker can view the jobs they have applied for, very simple. When they &#8220;apply&#8221; this application is stored in the database table &#8216;applications&#8217; with a &#8216;job_id&#8217; column which stores the &#8216;id&#8217; of the job from the &#8216;jobs&#8217; database table. At the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3329","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3329","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=3329"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3329\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3329"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3329"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3329"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}