尽管有“未定义的偏移量”错误,但以下功能仍能正常工作,但我还需要调试它。有人可以帮我找出错误的位置吗?
这是表格:
$query = "SELECT * FROM application WHERE Shortlist_status = 1 AND Interview_datetime != '' AND Email_checked ='' ORDER BY Candidate_id ASC";
$result = mysqli_query($link, $query) or die(mysqli_error($link));
while ($row = mysqli_fetch_array($result)) {
<input type="hidden" name="can_id[]" value=<?php echo $canid ?>>
<input type="hidden" name="job_id[]" value=<?php echo $jobid ?>>
(Some codes)
<input name="email[]" id="id" type="checkbox" value="1">
}
这是表单处理:
foreach ($_POST['can_id'] as $i => $candidate_id) {
$job_id = $_POST['job_id'][$i];
$email = $_POST['email'][$i];
$insertQuery = "UPDATE application SET Email_checked = '$email' WHERE Candidate_id = $candidate_id AND Job_id = $job_id";
$inserted = mysqli_query($link, $insertQuery) or die(mysqli_error($link));
}
if($inserted)
{
$message = 'Application successfully update <br><a href="interview.php">Manage Candidate</a>';;
}
else
{
$message = 'Application failed <br><a href="interview.php">Manage Candidate</a>';
}
echo $message;
答案 0 :(得分:1)
根据您在评论中描述错误的方式,我猜这个问题可以这样解决:
$email = isset($_POST['email'][$i]) ? $_POST['email'][$i] : "otherValue";
将"otherValue"
替换为未设置的任何内容(可能是"0"
)
答案 1 :(得分:-1)
$email = isset($request->email[$i]) ? $request->email[$i] : 0;