Input checkbox value that is created dynamically into MySQL if checked
<p>I am pulling in questions from a questions table in MySQL and populating them in a form. This works fine and I am populating checkboxes as well that the value is populated with the QuestionID. The array is properly populating but I want to take the value of the checked checkboxes (which is my question ID) and insert that ID into a table, so that I have the questions that are selceted for use by their ID. Here is what I have so far:</p>

<pre><code>//Declare the QuestionID as a array
$QuestionID = array();


while($row = mysqli_fetch_array($run,MYSQLI_ASSOC)){
echo '&lt;div id="QuestionSelection"&gt;&lt;input id="chkQuestion" type="checkbox" value=" '.$row['QuestionID'].'" name=chkQuestion align="left"/&gt;&lt;p&gt;' . $row['Question'] .'&lt;/p&gt;&lt;/div&gt;&lt;br/&gt;&lt;br/&gt;';

//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 '&lt;h1&gt;Submitted!!&lt;/h1&gt;';

}


}//End of IF 'submitted
</code></pre>
