All,
I'm having problems displaying the results from a query.
I am building the results from a questionnaire and have 10 questions which have 4 possible answers each (they were radio boxes). What I would like to do is to display the question on the left and the counts of each answer type in the same row - e.g.
--------------------AT1-----AT2-----AT3-----AT4
Question 1-------13-------8--------0--------5---
where AT is the answer type.
My query is as follows:
$result = mysql_query("select question_id, answer_type_id count(answer_type_id) as qty from answer GROUP BY question_id, answer_type_id;");
So this returns a list of question id's, answer_type id's and a count of how many was selected.
How can I display the data like above?
if question_id = 1 and answer_type_id = 1 - display results (13)
if question_id = 1 and answer_type_id = 2 - display results (8)
if question_id = 1 and answer_type_id = 3 - no results - return 0
if question_id = 1 and answer_type_id = 4 - display results (5)
any ideas?
I'm having problems displaying the results from a query.
I am building the results from a questionnaire and have 10 questions which have 4 possible answers each (they were radio boxes). What I would like to do is to display the question on the left and the counts of each answer type in the same row - e.g.
--------------------AT1-----AT2-----AT3-----AT4
Question 1-------13-------8--------0--------5---
where AT is the answer type.
My query is as follows:
$result = mysql_query("select question_id, answer_type_id count(answer_type_id) as qty from answer GROUP BY question_id, answer_type_id;");
So this returns a list of question id's, answer_type id's and a count of how many was selected.
How can I display the data like above?
if question_id = 1 and answer_type_id = 1 - display results (13)
if question_id = 1 and answer_type_id = 2 - display results (8)
if question_id = 1 and answer_type_id = 3 - no results - return 0
if question_id = 1 and answer_type_id = 4 - display results (5)
any ideas?
Comment