我在视图中有一个复选框列表,这些复选框是通过foreach循环form_checkbox('jobseeker[]', $application['jobseeker_profile_id']);
生成的。
目前我已经生成了2行但是在点击提交按钮时似乎有问题。检查生成的第一个复选框后,当我点击提交按钮时,我收到错误Undefined variable: candidates
和foreach错误,当我在检查两个复选框生成后点击提交按钮时出现错误Undefined variable: candidates
但是当我只检查时第二个复选框我没有错误,它会在下一页上做它应该做的事情。
我问的是我当前代码有什么问题会阻止多个复选框被点击而不会出错?
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);
输出视图
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();
非常感谢。