Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9139193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:21:21+00:00 2026-06-17T09:21:21+00:00

Newbie here. I am trying to display more than one Multiple questions on a

  • 0

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.

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.

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.

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.

<body style="margin: 100px;">
    <?php foreach ($questions as $question) : ?>
        <small>(<?php echo $question['qid']; ?>)</small>
        <strong><?php echo $question['qdesc']; ?></strong>

        <ol>
           <?php foreach ($answers[$question['qid']] as $answer) : ?>
                <li><label><input type="radio" name=$question['qid'] value=$answer['aid']><?php  echo $answer['adesc']; ?></label></li>               
           <?php endforeach; ?>
        </ol>
    <?php endforeach; ?>
</body>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:21:22+00:00Added an answer on June 17, 2026 at 9:21 am

    Your radio button name has PHP code that is missing the opening and closing PHP tags (also missing quotes):

    <li><label><input type="radio" name="q_<?php echo $question['qid']; ?>" value="<?php echo $answer['aid']; ?>"><?php  echo $answer['adesc']; ?></label></li>               
    

    You might also want to include a prefix (as above) so that the names are not just numbers.

    Because your radio groups all had the same name, it meant that were all treated as a single group and so only lets you select one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am more than convinced that similar questions have been asked here but I
newbie here, first post. I just spent like 4 hours trying to assign one
Java newbie here, I am trying to find the output of the following chunk
Javascript newbie here, trying to load Twitter profile images using the URLs returned by
I'm a newbie to sql and am trying to follow this example here: http://net.tutsplus.com/tutorials/php/a-better-login-system/
jQuery-newbie here. I want to do a simple horizontal scroll function with two buttons.
Newbie here. I am trying to store the result of my search onto a
VBA newbie over here. I'm trying to use an array formula through excel vba
awk newbie here.. I'm trying this: top -b -p 30259 | awk 'BEGIN {
Newbie here with a frustrating, but probably simple question. I am trying to write

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.