Hi, I'm working on a mysql-based survey program. On the user page I display the survey form, and on the admin page I display the results for each question. The problem, which I find puzzling, is that on the results page the order of the questions (sorted by specified question numbers) are slightly jumbled, while on the user form they work fine. I've looked at these mysql queries for a while but can't seem to pinpoint the problem. I'll paste them below and if you notice anything out of the ordinary please let me know.
*Edit: I'm posting these as plain text - didn't format well in the [code] tags...
Here's the one for the userform, which works fine:
SELECT questions.question_type_id,questions.question_id,q uestions.question_text,questions.show_comment,ques tion_choice_group.question_group_array from questions LEFT JOIN question_choice ON (questions.question_id = question_choice.question_id) AND (question_choice.survey_id = '$survey_id') LEFT JOIN question_choice_group USING (question_choice_group_id) WHERE questions.survey_id = '$survey_id' ORDER BY questions.question_order_num
Here's the one for the results page, whose order doesn't quite work:
SELECT questions.survey_id,questions.question_id,question s.question_text,answers.answer_text,questions.ques tion_type_id,question_choice.question_choice_group _id,question_choice_group.question_group_array,
count(answers.answer_text) as 'num_answers',questions.question_order_num
FROM questions LEFT JOIN answers ON (questions.question_id = answers.question_id AND questions.survey_id = answers.survey_id)
LEFT JOIN question_choice ON (questions.question_id = question_choice.question_id AND questions.survey_id=question_choice.survey_id)
LEFT JOIN question_choice_group ON question_choice.question_choice_group_id = question_choice_group.question_choice_group_id
WHERE questions.survey_id='$survey_id'
GROUP BY questions.question_text,answers.answer_text
ORDER BY questions.question_order_num