Adding up results
Okay, I have a table with user results from a questionnaire... each row is the user id, question id and number of points from each question.
I want to be able to add up the points of each row (theres 20 questions in total)... whatever method I've tried has failed so far... my current "debug" function is:
function getResults($aID)
{
for($i = 1; $i <= 20; $i++) {
$sql = "SELECT rAID FROM qResults WHERE rUID = ". $aID ." AND rQID = ". $i;
$q = mysql_query($sql,$this->getConnection());
$r = mysql_fetch_array($q);
$p[$i] = $r["rAID"];
}
return $p[1] ." ". $p[2] ." ". $p[3] ." ". $p[4] ." ". $p[5] ." ". $p[6] ." ". $p[7] ." ". $p[8] ." ". $p[9] ." ". $p[10] ." ". $p[11] ." ". $p[12] ." ". $p[13] ." ". $p[14] ." ". $p[15] ." ". $p[16] ." ". $p[17] ." ". $p[18] ." ". $p[19] ." ". $p[20];
}
}
Any help would be much appreciated :)
~ Willmo
Subject
Written By
Posted
Adding up results
July 28, 2005 10:25AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.