我正在使用此代码将值存储在数据库中,但是当我选择多个复选框时,只有一个 eid 值存储在数据库中(这应该不是我选择的复选框),并且 rid 值也存储为 0 在哪里错误?这是php代码
<?php //insert selected candidate in table
//echo "checkcandi".$_POST['check_candi'];
if(isset($_POST['select_candidate']) && logged_in())
{
$checkcandi_sel = $_POST['check_candi'];
if(empty($checkcandi_sel))
{
echo("You didn't select any Candidates.");
}
else
{
$N = count($checkcandi_sel);
echo("You selected $N Candidate(s): ");
for($i=0; $i < $N; $i++)
{
echo($checkcandi_sel[$i] . " ");
$eid=$checkcandi_sel[$i];
echo "candi id".$eid;
}
}
//$rid=$value[1];
if(logged_in())
{
$emplyrid=$_SESSION['uid'];
echo "emplyrid".$emplyrid;
}
//$rid=$_GET['rid'];
//var_dump($emplyrid);
$query = "INSERT INTO selected_candidate (
eid,rid
) VALUES (
'{$eid}','{$emplyrid}'
)";
$result = mysql_query($query, $connection);
if ($result) {
$message = "<p style=\"color:green\">The Candidate selected and saved to your my seleted.</p>";
} else {
$message = "Sorry job was not applied.";
$message .= "<br />" . mysql_error();
}
}
?>
这是复选框的代码
echo "<td><input id=\"select_candi{$i}\" onclick=\"javascript:func(this.id,{$_SESSION['uid']})\" type=\"checkbox\" name=\"check_candi[]\" value=\"{$data_set['eid']}\"/></td>";