for($j = 0; $j < $length; $j++){
while($answersRow = mysql_fetch_row($fetch)){
if($answersRow[0] == $curr_answer_id[$j]){
echo "<input type='checkbox' value='$answersRow[0]' checked>$answersRow[1]</input> ";
} else {
echo "<input type='checkbox' value='$answersRow[0]'>$answersRow[1]</input> ";
}
}
}
Assuming $fetch
is my result, here's my dilemma. The for
loop represents the array of checkboxes
. The first loop around, everything works fine. However, any more than that, we no longer cycle through the while loop
because of the internal mysql pointer. I know I can move the pointer around using mysql_data_seek()
, but don't have an idea on how to do so usefully. If I move it back to 0, then it just outputs everything for as many things that were checked.
I basically want to traverse through for each question through the database but without any overlap. It is a bit hard to explain so I apologize if I am not explaining this simple problem properly; I'll try and clarify if need be.