Somebody help me with this query. I have a raw score from a test. I get the number of questions for this test and then try to update the grade.
This gets the number of questions that were on the test.
$getnumquestions = $db->sql_query("SELECT num_quest_irat FROM ".$prefix."_tl_session WHERE Session_ID = '$Session_ID'");
while($info = $db->sql_fetchrow($getnumquestions)) {
$NumQuestions = $info['num_quest_irat'];
}
The next code is trying to update the table and set a value for IRAT_Grade.
$updateIRAT_Grade = $db->sql_query("UPDATE ".$prefix."_tl_session_grades sg
JOIN ".$prefix."_tl_session s
SET IRAT_Grade = (SELECT ((IRAT_Raw / $NumQuestions) * 100) AS IRATGrade)
WHERE sg.Session_ID = s.Session_ID");
if (!$updateIRAT_Grade) {
echo("<p>Error performing query: " . mysql_error() . "</p>");
exit();
}
Currently I am getting an error:
Error performing query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') * 100) AS IRATGrade) WHERE sg.Session_ID = s.Session_ID' at line 3