MySQL の質問テーブルから質問を取り込み、フォームに入力しています。これは正常に機能し、値に QuestionID が入力されるようにチェックボックスも入力しています。配列は適切に入力されていますが、チェックされたチェックボックスの値 (質問 ID) を取得し、その ID をテーブルに挿入して、ID で使用するために選択された質問を作成したいと考えています。これが私がこれまでに持っているものです:
//Declare the QuestionID as a array
$QuestionID = array();
while($row = mysqli_fetch_array($run,MYSQLI_ASSOC)){
echo '<div id="QuestionSelection"><input id="chkQuestion" type="checkbox" value=" '.$row['QuestionID'].'" name=chkQuestion align="left"/><p>' . $row['Question'] .'</p></div><br/><br/>';
//Assign the QuestionID from the table to the var
$QuestionID[] = $row['QuestionID'];
}
if($_POST['submitted']) {
if (isset($_POST['chkQuestion']))
{
//create the query for the score
$sql2 = "INSERT INTO tbl_QuestionSelected (`QuestionID`) VALUES ($QuestionID)";
//Run the query
$run2 = @mysqli_query ($conn,$sql2);
//Confirm message data was entered with a correct response and a graphic
echo '<h1>Submitted!!</h1>';
}
}//End of IF 'submitted