title: HTML - PHP More than one multiple choice questn in a form, can select only one radio button.
body: <p>Newbie here. I am trying to display more than one Multiple questions on a form with multiple choice answers displayed as radio buttons. A user should be able to select one answer(radion button) per question. </p>
  
  <p>My problem is that once I display the questions and the answers, I can only select one radio button on the form(not per question). In the code below, qid is the question Id and aid is the answer Id. For each question retrieved from the database, the radio button group would get the question number assigned to the name.</p>
  
  <p>For ex: question 1 has 4 multiple choice answers with name = 1 , question 2 has 4 multiple choice answers with name = 2 and so on. </p>
  
  <p>So when the user selects an answer for question 1 and picks an answer to question 2, the selected answer for question 1 is cleared. </p>
  
  <pre><code>&lt;body style="margin: 100px;"&gt;
      &lt;?php foreach ($questions as $question) : ?&gt;
          &lt;small&gt;(&lt;?php echo $question['qid']; ?&gt;)&lt;/small&gt;
          &lt;strong&gt;&lt;?php echo $question['qdesc']; ?&gt;&lt;/strong&gt;
  
          &lt;ol&gt;
             &lt;?php foreach ($answers[$question['qid']] as $answer) : ?&gt;
                  &lt;li&gt;&lt;label&gt;&lt;input type="radio" name=$question['qid'] value=$answer['aid']&gt;&lt;?php  echo $answer['adesc']; ?&gt;&lt;/label&gt;&lt;/li&gt;               
             &lt;?php endforeach; ?&gt;
          &lt;/ol&gt;
      &lt;?php endforeach; ?&gt;
  &lt;/body&gt;
  </code></pre>