I have a group of checkboxes each with the name attribute "question_id[]". Additionally I have a selectbox that passes a singular value of survey_id. These values are passed via the form to:
$survey_id= $_POST['survey_id'];
foreach($_POST['question_id'] as $question_id) {
$sql=("INSERT INTO questions_questionnaires (question_id, survey_id) VALUES ('$question_id', '$survey_id')");
mysqli_query($con,$sql);
if (!mysqli_query($con,$sql)) {
die('Error: ' . mysqli_error($con));
}
}
Each value in the 'question_id' array is being inserted twice into the DB. Any ideas?