I have an list of checkboxes within a view which are generated through a foreach loop form_checkbox('jobseeker[]', $application['jobseeker_profile_id']);
.
At the moment I have 2 rows generated from this but there seems to be a problem when hitting the submit button. When I hit the submit button after checking the 1st checkbox generated I get an error Undefined variable: candidates
and foreach errors, When I hit the submit button after checking both checkbox's generated I get an error Undefined variable: candidates
but when I only check the second checkbox I get no errors and it does what it should do on the next page.
I'm asking is what is wrong with my current code which would prevent multiple checkboxes to be clicked without error?
CHECKBOX VIEW
foreach($applications as $application){
$value = $application['points_value'] * $this->session->userdata('price');
echo "<tr class=\"row\" style=\"background: green\">";
echo "<td class=\"column\">";
echo $application['name'];
echo "</td>";
echo "<td class=\"column\">";
foreach($skills as $myskills){
echo $myskills[$i]['name'];
}
echo "</td>";
echo "<td class=\"column\">";
foreach($qualifications as $myqualifications){
echo $myqualifications[$i]['name'];
}
echo "</td>";
echo "<td class=\"column\">";
foreach($workhistory as $myhistory){
echo $myhistory[$i]['role'];
}
echo "</td>";
echo "<td class=\"column\">";
echo form_open('resume');
echo form_hidden('jobseeker_id', $application['jobseeker_profile_id']);
echo form_submit('submit'.'" class="submitButton"', 'View CV');
echo form_close();
echo "</td>";
echo "<td class=\"column\">";
echo $value;
echo "</td>";
echo "<td class=\"column\">";
echo form_open('applications/interview');
echo form_checkbox('jobseeker[]', $application['jobseeker_profile_id']);
echo "</td>";
echo "</tr>";
$i++;
}
echo form_submit('Submit'.'" class="submitButton"', 'Continue');
echo form_close();
CONTROLLER
$this->load->view('header');
$applicants = $this->input->post('jobseeker');
$data = array();
foreach($applicants as $applicant => $id){
$data['candidate'] = $this->db->get_where('jobseeker_profiles', array('id' => $id ))->row_array();
$data['candidates'][] = $data['candidate'];
}
$this->load->view('payment', $data);
OUTPUT VIEW
foreach($candidates as $candidate){
$value = $candidate['total_points_value'] * $this->session->userdata('price');
echo $candidate['name']." - "."£".number_format($value, 2, '.', '');
$total += $value;
}
echo "<br><br>";
echo "Total Payment: £".number_format($total, 2, '.', '');
echo form_open('applications/payment');
echo form_hidden('amount'.'" value="'.$total.'');
echo form_submit('submit'.'" class="submitButton"', 'Make Payment');
echo form_close();
Many Thanks.
echo
your table so hard? – Jari Sep 5 at 12:09