<?php for($i=0; $i< mysqli_num_rows($result); $i++){ ?>
<table id="t01" style="width:100%">
<tr>
<th colspan="2"><?php print_r($results[$i]['arr_question']); ?></th>
</tr>
<tr>
<td><?php print_r($results[$i]['a']); ?></td>
<td><?php print_r($results[$i]['b']); ?></td>
</tr>
<tr>
<td><?php print_r($results[$i]['c']); ?></td>
<td><?php print_r($results[$i]['d']); ?></td>
</tr>
<tr>
<td colspan="2"><button type="button" onClick="document.getElementById('').innerHTML= '<?php print_r($results[$i]['answer']); ?>'"> Answer </button>
<p id=''></p>
</td>
</tr>
<tr> <td colspan="2"><?php print_r($results[$i]['description']); ?></td>
</tr>
</table>
</br>
<?php } ?>
In this code document.getElementById('').innerHTML
is not working properly, it returns the same value while clicking on button in loop, when i put id equals $i
it return the value in same place at every loop, it overrides the data at same place, when i put any static value it returns same. What should i do for getting the different value at different places. Any help will be appreciable.