Craigr
04-05-2003, 11:48 AM
// Quiz Addon
$quiznamez=$DB_site->query_first("SELECT quiztitle, description, quizid, timestamp FROM quiz ORDER BY quizid ASC LIMIT 10");
$quizresults=$DB_site->query_first("SELECT totalcorrect, resulttime FROM quiz_results WHERE userid = '$userinfo[userid]' ORDER BY quizid ASC LIMIT 10");
$totalquestions=$DB_site->query_first("SELECT COUNT(quizid) AS questions FROM quiz_questions WHERE quizid='$quiznamez[quizid]'");
$questions = $totalquestions[questions];
$numA = $quizresults[totalcorrect];
$numB = $questions;
$percentage = $numA/$numB*100;
$dateposted = date("D j M Y, g:i A",$quiznamez[timestamp]);
$taken = date("D j M Y, g:i A",$quizresults[resulttime]);
$quizname .="<tr><td bgcolor='#F1F1F1' width=20%><normalfont><b>$quiznamez[quiztitle]</b></normalfont> <smallfont>[ <a href=\"quiz.php?s=&quizid=$quiznamez[quizid]\">Take Quiz</a> ]<br><smallfont>$quiznamez[description]<br><i>Created: $dateposted</i></smallfont></td><td bgcolor='#F1F1F1' width=20%><normalfont>$quizresults[totalcorrect] correct from $questions questions. Giving a percentage of $percentage%.</normalfont><br><smallfont><i>Quiz completed: $taken</i></smallfont></td></tr>\n";
// End Quiz Addon
I've been trying for ages now to make the above query loop. This is the first time i've tried to make any SQL.
The above is an addon i was making for the quiz. In the member profile i hope to pull the quiz names and the person's
results and put them at the bottom of the profile.
At the moment the above just pulls one quiz name and one result. I want it to keep going until all the
quiz names/results are displayed. I think you use while, but i'm not sure.
Could someone help? Also could you let me know if any of the above is wrong.
Thanks
Craig
$quiznamez=$DB_site->query_first("SELECT quiztitle, description, quizid, timestamp FROM quiz ORDER BY quizid ASC LIMIT 10");
$quizresults=$DB_site->query_first("SELECT totalcorrect, resulttime FROM quiz_results WHERE userid = '$userinfo[userid]' ORDER BY quizid ASC LIMIT 10");
$totalquestions=$DB_site->query_first("SELECT COUNT(quizid) AS questions FROM quiz_questions WHERE quizid='$quiznamez[quizid]'");
$questions = $totalquestions[questions];
$numA = $quizresults[totalcorrect];
$numB = $questions;
$percentage = $numA/$numB*100;
$dateposted = date("D j M Y, g:i A",$quiznamez[timestamp]);
$taken = date("D j M Y, g:i A",$quizresults[resulttime]);
$quizname .="<tr><td bgcolor='#F1F1F1' width=20%><normalfont><b>$quiznamez[quiztitle]</b></normalfont> <smallfont>[ <a href=\"quiz.php?s=&quizid=$quiznamez[quizid]\">Take Quiz</a> ]<br><smallfont>$quiznamez[description]<br><i>Created: $dateposted</i></smallfont></td><td bgcolor='#F1F1F1' width=20%><normalfont>$quizresults[totalcorrect] correct from $questions questions. Giving a percentage of $percentage%.</normalfont><br><smallfont><i>Quiz completed: $taken</i></smallfont></td></tr>\n";
// End Quiz Addon
I've been trying for ages now to make the above query loop. This is the first time i've tried to make any SQL.
The above is an addon i was making for the quiz. In the member profile i hope to pull the quiz names and the person's
results and put them at the bottom of the profile.
At the moment the above just pulls one quiz name and one result. I want it to keep going until all the
quiz names/results are displayed. I think you use while, but i'm not sure.
Could someone help? Also could you let me know if any of the above is wrong.
Thanks
Craig