title: Submitting multiple fields in a form (PHP)
body: <p>I currently have a page which dynamically fills in a survey (Questions, Answers as Radio Buttons/Checkboxes) from a MySQL database. The generated HTML looks something like this :</p>
  
  <pre><code>  &lt;form id="form1" name="form1" method="post" action=""&gt;
    1 . How do you classify yourself?
    &lt;br/&gt;
         &lt;input type="radio" name="radio[0]" id="radio[0]" value="Alien" /&gt;Alien     
     &lt;br /&gt;
         &lt;input type="radio" name="radio[0]" id="radio[1]" value="Hobbit" /&gt;Hobbit     
     &lt;br /&gt;
         &lt;input type="radio" name="radio[0]" id="radio[2]" value="Tree" /&gt;Tree     
     &lt;br /&gt;&lt;br/&gt;
  
    2 . Who are you?
    &lt;br/&gt;
         &lt;input type="radio" name="radio[1]" id="radio[3]" value="Camel Collector" /&gt;Camel Collector     
     &lt;br /&gt;
         &lt;input type="radio" name="radio[1]" id="radio[4]" value="sadasd" /&gt;sadasd     
     &lt;br /&gt;
         &lt;input type="radio" name="radio[1]" id="radio[5]" value="Voolome" /&gt;Voolome     
     &lt;br /&gt;
         &lt;input type="radio" name="radio[1]" id="radio[6]" value="31231235" /&gt;31231235     
     &lt;br /&gt;
      &lt;br/&gt;
    3 . Test Question
    &lt;br/&gt;
         &lt;input type="radio" name="radio[2]" id="radio[7]" value="Nobody Knows" /&gt;Nobody Knows     
     &lt;br /&gt;
         &lt;input type="radio" name="radio[2]" id="radio[8]" value="Somebody Knows" /&gt;Somebody Knows     
     &lt;br /&gt;
         &lt;input type="radio" name="radio[2]" id="radio[9]" value="Who Knows" /&gt;Who Knows     
     &lt;br /&gt;
      &lt;br/&gt;
    4 . Test Question 2
    &lt;br/&gt;
         &lt;input type="radio" name="radio[3]" id="radio[10]" value="Answer1" /&gt;Answer1     
     &lt;br /&gt;&lt;br/&gt;
    5 . First Multiple
    &lt;br/&gt;
        &lt;input type="checkbox" name="Check4" value="Bike"&gt;Answer One&lt;br&gt;
  
     &lt;br /&gt;
        &lt;input type="checkbox" name="Check4" value="Bike"&gt;Answer Two&lt;br&gt;
  
     &lt;br /&gt;
        &lt;input type="checkbox" name="Check4" value="Bike"&gt;Answer Three&lt;br&gt;
  
     &lt;br /&gt;&lt;br/&gt;
    6 . First Open!
    &lt;br/&gt;
        &lt;input type="text" name="Ans5" /&gt;
  
     &lt;br /&gt;&lt;br/&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>A few important things to note :</p>
  
  <ol>
  <li>There are 3 types of questions, "Choice" - Single choice(Radio Button); "Multiple" - Multiple Choice(Check box); "Open" - User Input (Text Box).</li>
  <li>Each element's name corresponds to the appropriate question number (The number shown next to the question is Question+1 (Since it starts at 0). [For example, Question 14 would have Radio[14] as the name.</li>
  </ol>
  
  <p>My Main Question : How can you submit these fields to be stored into the Database? I am trying to figure out how to write code which will find out which option is selected for each question.</p>
  
  <p>Side Question : Is it also possible to validate these questions to ensure atleast one option is selected for each question? (Checking that textbox!="" is easy, but how would I do this for Radio Button/Checkboxes?)</p>
  
  <p><strong>PHP Code used to generate this form can be provided if needed! It is essentially using one variable to store the question number ($qno), which is used as a counter while looping the statements to pull data from MySQL, Figure out the type of answer, and place the appropriate controls on the form.</strong></p>