Good day! I would like to ask for help.
I'm currently making an Evaluation System for my school project. In my code, I can generate ALL the questions in my dbase together with 5 checkboxes.
e.g. If I add a new question to a particular criteria, it will be show to a table together with 5 auto-generated checkboxes.
how can I auto increment the name and value of my checkbox so if I save them to my dbase the value will be incremented every time there's a new question added?
I currently have 5 criterias, each have 5 questions and 5 sets of checkbox each. consisting of 25checkbox per criteria, but they have the same value and name when auto-generating.
<?php
$sql = "SELECT * FROM question_pool_registrar WHERE criteria_id = 1";
$result = $connect->query($sql);
if($result->num_rows > 0){
$nr = 0;
while($row = $result->fetch_assoc()){
$question = $row['question'];
echo "<tr>
<td>$question</td>
<td><input type='checkbox' value=\"1c5".$nr."\" name=\"answer1".$nr."\" class='radio'></td>
<td><input type='checkbox' value=\"1c4".$nr."\" name=\"answer1".$nr."\" class='radio'></td>
<td><input type='checkbox' value=\"1c3".$nr."\" name=\"answer1".$nr."\" class='radio'></td>
<td><input type='checkbox' value=\"1c2".$nr."\" name=\"answer1".$nr."\" class='radio'></td>
<td><input type='checkbox' value=\"1c1".$nr."\" name=\"answer1".$nr."\" class='radio'></td>
</tr>";
$nr++;
}
}
?>