I have a quiz and one quiz have multiple checkbox questions. How to make all the checkbox name differently so I can retrieve correctly?
Html:
foreach($questionSetArr as $question){
$questionID = $question['question_id'];
$getListOfOptions = getOptionsList($questionID);
foreach($getListOfOptions as $option){
$optionDesc = $option['option_desc'];
echo "<div class='checkbox'>
<label><input type='checkbox' value='$optionDesc' name='cb[$questionID]' id='$questionID' >$optionDesc</label>
</div>";
}
}
PHP:
$questionID = $qIDArr[$x];
echo "<br>User Answer for Question $questionID : ";
$selectedQuestion= $_POST["cb"];
print_r($selectedQuestion);
foreach ($selectedQuestion as $sQ){
echo $sQ;
}
Currently, they will retrieve wrongly. How to solve it ?
Aucun commentaire:
Enregistrer un commentaire