Hi, i'm rewriting a quiz script im working on becuase i found a better way to do it. This is going to be much "smarter" than the original. This piece of code is loading the questions from a file on the server. but im having a small problem. the $data[$n] part is not working. i replaced it with a text string and then the code worked so it's defently that part.
here is the code that is causing the problem, i've already pulled the $questioncount from the file, and everything else needed except for the questions and choices.
$n = 6;
if ($qc = fopen($quizfile, "r"))
{
for ($i=0; $i <= $questioncount; $i++)
{
while ($data = fgetcsv ($qc, 1000, "%"))
{
${"q0" . $i . "01"} = $data[$n]; //Question
$n++;
${"q0" . $i . "02"} = $data[$n]; //Choice 1
$n++;
${"q0" . $i . "03"} = $data[$n]; //Choice 2
$n++;
${"q0" . $i . "04"} = $data[$n]; //Choice 3
$n++;
${"q0" . $i . "05"} = $data[$n]; //Choice 4
$n=$n+2; //skip the answer
//${"q0" . $i . "06"} = $data[$n]; //Answer
//$n++;
}
}
fclose($qc);
}
Quiz Name%Quiz Creator%5 (number of questions)%4.50 (Rating)%4 (Votes)%password%
This is question 1%Choice 1%Choice 2%Choice 3%Choice 4%a%
This is question 2%Choice 1%Choice 2%Choice 3%Choice 4%b%
This is question 3%Choice 1%Choice 2%Choice 3%Choice 4%c%
This is question 4%Choice 1%Choice 2%Choice 3%Choice 4%d%
This is question 5%Choice 1%Choice 2%Choice 3%Choice 4%a
anything in ( ) is not included in the file, its just to tell you what it is. also, linebreaks were added for the forums.