my problem is that i have two tables (test and result) both of which have a field called score, but both score fields hold different values one holds all the question answer scores (test), the other holds the score for the users answers(result) i need to be able to select them individually so i can add the scores together to get a percentage.
the format the scores are in the database is like 1,2,2,3,4,
plan is to:-
-
select score from test
-
load into a array
-
add values together
-
store as $tscore;
-
select score from result
-
load into array
-
add values together
-
store as $rScore
-
deduct $rScore from $tScore
-
multiply by 100
-
store value as $total
[php]
$qry = mysql_query(“SELECT Result., Test.
FROM
Result INNER JOIN Test
ON Result.testID = Test.testID
WHERE userID = ‘$_REQUEST[selectedUser]’;”);
while($row = mysql_fetch_array($qry)){$_SESSION['score'] = $row['score']; $arrScore=(explode(',', $_SESSION['score'], -1)); $tScore =array_sum($arrScore);
[/php]
the code above is ok but i cant distinguish between the two fields how can i fix this??