1

I have the following code:

<select id='rq1' class='business' name='q1'>
  <option value='1'>1</option>
  <option value='2'>2</option>
</select>
<select id='rq2' class='business' name='q1'>
  <option value='1'>1</option>
  <option value='2'>2</option>
</select>
<select id='rq3' class='business' name='q1'>
  <option value='1'>1</option>
  <option value='2'>2</option>
</select>

Fiddle: http://jsfiddle.net/NMQz8/

What I am trying to understand is if it is possible to save the responses from each of the dropdowns to an Array. The reason for this is so that I can save the results into one column in the database as opposed to having a column for each dropdown response. Does that make sense?

Is this possible, is it as straightforward as adding [] to the name and then unserializing them to post to the database?

1 Answer 1

1

Do you mean

<?php
    var_dump($_POST);
?>
<form method='post'>
    <select id='rq1' class='business' name='q1[]'>
      <option value='1'>1</option>
      <option value='2'>2</option>
    </select>
    <select id='rq2' class='business' name='q1[]'>
      <option value='1'>1</option>
      <option value='2'>2</option>
    </select>
    <select id='rq3' class='business' name='q1[]'>
      <option value='1'>1</option>
      <option value='2'>2</option>
    </select>
    <input type='submit'>
</form>

When you submit the form, you will get data in Array.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes - that is correct, exactly. So I treat the dropdowns in the same way as any other input method?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.