function test_score($test_id,$page,$user_id)
{
GLOBAL $con;
$count=0;
$query=mysqli_query($con,"SELECT user_id, test_id,
SUM(status='correct') AS correct_answers,
SUM(status='incorrect') AS incorrect_answers
FROM (SELECT qa.question_id, qa.test_id, uta.user_answer,uta.user_id, qa.type,
qa.answers correct_answer,
CASE WHEN uta.user_answer = qa.answers THEN 'correct' ELSE 'incorrect' END
AS status
FROM questions_answer qa
LEFT JOIN
(
SELECT user_id, type, test_id, question_id,
GROUP_CONCAT(answers ORDER BY answers) AS user_answer,
timestamp from user_test_answers
WHERE test_id = '$test_id'
GROUP BY user_id, question_id
) uta
ON qa.question_id = uta.question_id
where qa.test_id=1 AS results
GROUP BY user_id, test_id
ORDER BY user_id, test_id ");
while($result=mysqli_fetch_assoc($query))
{
$answer_correct=$result['results'];
if($answer_correct=="correct")
{
$count++;
}
}
return $count;}
what value does $count return..i want to get the value of top3 scorers using value in correct answers from above query...how to get maximum value out of correct answers field as well as count the no of correct answers to b stored in database..plz help..i am not able to understand this code