Jump to content

Finding totals for multiple answer question


guttyguppy

Recommended Posts

I'm building a survey, and most of the questions are multiple choice, i.e. radio buttons. I can easily find the total for each answer with queries like:

 

select count(*) FROM survey where question3='answer5'

 

However, one question is multiple answer, i.e. checkboxes. In this case, each submission may have more than one answer. In my processor script, I'm storing the data using the php serialize function, like:

 

$multipleAnswer = serialize($_POST["multipleAnswer"]);

 

so the data should be getting stored correctly, I hope. But I'm not sure how structure the query to fetch totals for each answer, if the user has chosen more than one.

 

I hope I'm being clear enough, and thanks for your help.

 

 

Link to comment
Share on other sites

OK, I'm guessing that would entail making a table just for that one question? How would I query that table to tally up the votes for submissions that list more than one answer?

No -- one table of answers, linked to question_id.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.