diff --git a/questions.inc.php b/questions.inc.php index 09ca213..dc1bfc1 100644 --- a/questions.inc.php +++ b/questions.inc.php @@ -26,16 +26,15 @@ function questions_load_answers($section, $users_id) { - $q = mysql_query('SELECT question_answers.*, questions.* '. - 'FROM question_answers '. - 'LEFT JOIN questions ON questions.id=question_answers.questions_id '. - "WHERE users_id='$users_id' ". - " AND questions.section='$section' ". - 'ORDER BY questions.ord ASC'); - - $ans = array(); - while($r=mysql_fetch_object($q)) { - $ans[$r->questions_id] = $r->answer; + global $config; + $yearq=mysql_query("SELECT `year` FROM users WHERE id='$users_id'"); + $yearr=mysql_fetch_object($yearq); + $ans=array(); + $qs=questions_load_questions($section,$yearr->year); + foreach($qs AS $id=>$question) { + $q=mysql_query("SELECT * FROM question_answers WHERE users_id='$users_id' AND questions_id='$id'"); + $r=mysql_fetch_object($q); + $ans[$id]=$r->answer; } return $ans; }