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 8210783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:11:44+00:00 2026-06-07T10:11:44+00:00

How can i save all the inputs(question, choices, answers) in the database? I cant

  • 0

How can i save all the inputs(question, choices, answers) in the database?
I cant save the correct answer on the database. how can i get the chosen value, which is selected through the radio button? Or is there any other?

<form action="test2.php" method="post">
<?php
if($numMC > 0)
    {

echo "<b>"."MULTIPLE CHOICE QUESTIONS: Enter them below followed by their correct answer."."</b>";
        echo "<br>"; 

        for ($j=1; $j<=$numMC; $j++)
            {?> 
<p><textarea name="question[<?php echo $j; ?>]" rows=3 cols=90>question[<?php echo $j; ?>]</textarea></p>
            <?php for($k=1;$k<=$numchoices;$k++)
                {
                echo $k; ?>
                <input type="radio" name="right[<?php echo $j; ?>]">
                <input type="text" name="choice[<?php echo $j; ?>][<?php echo $k; ?>]" value="choice[<?php echo $j; ?>][<?php echo $k; ?>]"><br />
<?php               }

                echo "<br>"."<br>";
            }

    } ?>

<input type="submit">     

how will i determine which radio button is selected and how will i get the value of the radio button that is selected?

  • 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-07T10:11:47+00:00Added an answer on June 7, 2026 at 10:11 am

    You can create a table with questions like so:

    ----------------------------------------------------
    | questionId | answer                    | correct |
    ----------------------------------------------------
    | 1          | Possible answer 1a        | 0       |
    ----------------------------------------------------
    | 1          | Possible answer 1b        | 1       |
    ----------------------------------------------------
    | 2          | Possible answer 2a        | 1       |
    ----------------------------------------------------
    | 2          | Possible answer 2b        | 0       |
    ----------------------------------------------------
    

    You can build the page like this:

    $sql = mysql_query("SELECT * FROM questionsTable");
    while($row = mysql_fetch_assoc($sql)){
    echo '<input type="radio" value="'.$row['answer'].'" name="q'.$row['id'].'"/>
    }
    

    You can check if the answers are correct after the form has been submitted like this:

    $sql = mysql_query("SELECT * FROM questions");
    while($row = mysql_fetch_assoc($sql)){
        $radioName = 'q'.$row['id'];
        if($row['correct'] == 1){
            //handle a correct answer here
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I get the Variables.save to save all variables, and not just the
All, I'm allowing my user to create questions which I'll need to save answers
how can I save all files in a directory using utf-8? There is a
Can I configure Redis slave to stop saving dumps? I have omitted all save
The question is: How to save user input linebreak to database. (jQuery/php/mysql) I have
I have a question. I need to save all values of my model. Class
First of all this is not a question about how can I use http
I've read through a lot of questions addressing similar question but I can't get
First of all I have seen SO many answers to a question like this,
I can save image to iPhone (iPhone Photo Albums \ Saved Photos) with UIImageWriteToSavedPhotosAlbum(image,

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.