AN-net
04-11-2004, 12:22 AM
hey guys, well see im trying to make it so for each question it will show all answers for that question but for some reason it is carrying over the questions from the last question and add those answers together.
see attachment for exmaple
heres my code:
$fquestions= $DB_site->query("SELECT question,question_id FROM ".TABLE_PREFIX."quiz_questions WHERE quiz_id='".$_REQUEST['q']."' AND active='1'");
while($question= $DB_site->fetch_array($fquestions))
{
$fanswers= $DB_site->query("SELECT answer,correct FROM ".TABLE_PREFIX."quiz_answers WHERE quiz_id='".$_REQUEST['q']."' AND question_id='".$question[question_id]."' AND active='1'");
while($answer= $DB_site->fetch_array($fanswers))
{
exec_switch_bg();
eval('$ansbits .= "' . fetch_template('quiz_correctansbits') . '";');
}
$DB_site->free_result($fanswers);
$userans= $DB_site->query_first("SELECT quiz_answers.correct AS useranscorrect,quiz_answers.answer AS userans FROM ".TABLE_PREFIX."quiz_useranswers LEFT JOIN quiz_answers ON (quiz_useranswers.answer_id=quiz_answers.answer_id ) WHERE quiz_useranswers.quiz_id='".$_REQUEST['q']."' AND quiz_useranswers.question_id='".$question['question_id']."'");
eval('$questionbits .= "' . fetch_template('quiz_statquestionbits') . '";');
}
eval('print_output("' . fetch_template('quiz_qbstatistics') . '");');
see attachment for exmaple
heres my code:
$fquestions= $DB_site->query("SELECT question,question_id FROM ".TABLE_PREFIX."quiz_questions WHERE quiz_id='".$_REQUEST['q']."' AND active='1'");
while($question= $DB_site->fetch_array($fquestions))
{
$fanswers= $DB_site->query("SELECT answer,correct FROM ".TABLE_PREFIX."quiz_answers WHERE quiz_id='".$_REQUEST['q']."' AND question_id='".$question[question_id]."' AND active='1'");
while($answer= $DB_site->fetch_array($fanswers))
{
exec_switch_bg();
eval('$ansbits .= "' . fetch_template('quiz_correctansbits') . '";');
}
$DB_site->free_result($fanswers);
$userans= $DB_site->query_first("SELECT quiz_answers.correct AS useranscorrect,quiz_answers.answer AS userans FROM ".TABLE_PREFIX."quiz_useranswers LEFT JOIN quiz_answers ON (quiz_useranswers.answer_id=quiz_answers.answer_id ) WHERE quiz_useranswers.quiz_id='".$_REQUEST['q']."' AND quiz_useranswers.question_id='".$question['question_id']."'");
eval('$questionbits .= "' . fetch_template('quiz_statquestionbits') . '";');
}
eval('print_output("' . fetch_template('quiz_qbstatistics') . '");');