This needs to pull the answer name with the results
This query works:
SELECT count(answer_id) as count FROM poll_answers WHERE poll_id='$poll_id' GROUP BY answer_id ORDER BY count DESC
But, I need it to do one more additional thing. I need it to join with the polls table on the value poll_id and get the text for the questions.
Then this is where it gets tricky...the name of the column it must pull the text from varies. There are ten of them: answer_1, answer_2, answer_3, answer_4, answer_5, answer_6, answer_7, answer_8, answer_9, answer_10. It has to grab from the right column. So if the poll_answers.answer_id for the result set if 5, it needs to get the text from polls.answer_5
The better I get at programming, the more I appreciate arrays. Handy dandy things they are.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)