I'm trying to get an array to print (echo) but cannot get it to work. The script goes something like this:-
if (something){
while ($row = mysql_fetch_array($display)) {
(Put the array values into variables each time round)
$id = $row["id"];
$question = $row["question"];
$opt1 = $row["opt1"];
$opt2 = $row["opt2"];
$opt3 = $row["opt3"];
$opt4 = $row["opt4"];
$answer = $row["answer"];
(Put the variables back into a different array to use later on)
$quiz = array(
'id' => $id,
'question' => $question,
'opt1' => $opt1,
'opt2' => $opt2,
'opt3' => $opt3,
'opt4' => $opt4,
'answer' => $answer);
Then I print this new array and it works fine.
} else if {
It is in this section that I want to print the quiz array, but I haven't managed to achieve that yet. Below is just one of the latest efforts:-
for ( $xx = 1; $xx < 16; $xx++ ){
echo "$xx >";
echo " $quiz[$id] ";
echo " $quiz[question] ";
echo " $quiz[opt1] ";
echo " $quiz[opt2] ";
echo " $quiz[opt3] ";
echo " $quiz[opt4] ";
echo " $quiz[answer]<br>";
}
}
I expect it is something quite simple, but I cannot find the answer so far. So any guidance would be greatly appreciated.
Terry