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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:13:25+00:00 2026-06-07T00:13:25+00:00

I am calling back the results for AnswerStatusID and AnswerResponse and need to apply

  • 0

I am calling back the results for AnswerStatusID and AnswerResponse and need to apply them to a variable to compare against to see if the answer given is correct or incorrect and the corresponding response for the answer, my issue is that my variable is only being populated by the last row in the table instead of populating it with all of the data.

// Connect to the Database
require_once('mysqli_connect.php');

//create the query for the question
$q = "SELECT `Question` FROM tbl_Question WHERE QuestionID = 1";

//Create the query for the Answers
$q2 = "SELECT `Answer`,`AnswerStatusID`,`AnswerResponse` FROM tbl_Answer WHERE QuestionID = 1";


//Run the query
$r = mysqli_query($conn,$q);

//run the answer query
$r2 = mysqli_query($conn,$q2);


while($row = mysqli_fetch_array($r,MYSQLI_ASSOC)){
echo '<div id="Question1"><p>1) ' . $row['Question'] . '</div></p>';
}



while($row2 = mysqli_fetch_array($r2,MYSQLI_ASSOC)){
echo '<div id="Question1"><input name="q1" type="radio" value="'.$AnswerStatusID.'"/>' . $row2['Answer'] . '</div><br/>';

//Assign the AnswerStatusID to a var
$AnswerStatusID = $row2['AnswerStatusID'];

//Assign the AnswerResponse to a var
$AnswerResponse = $row2['AnswerResponse'];
}
  • 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-07T00:13:25+00:00Added an answer on June 7, 2026 at 12:13 am

    As Wiseguy intimated, it looks like you want AnswerStatusID and AnswerResponse as arrays.

    Two steps here. First declare them as arrays.

    $AnswerResponse = array();
    $AnswerStatusID = array();
    

    Then store the values in each of them

    while($row2 = mysqli_fetch_array($r2,MYSQLI_ASSOC)){
        echo '<div id="Question1"><input name="q1" type="radio" value="'.$AnswerStatusID.'"/>' . $row2['Answer'] . '</div><br/>';
    
        //Assign the AnswerStatusID to a var
        $AnswerStatusID[] = $row2['AnswerStatusID'];
    
        //Assign the AnswerResponse to a var
        $AnswerResponse[] = $row2['AnswerResponse'];
    }
    

    You can then see what’s in the arrays using var_dump();

    var_dump($AnswerResponse)
    

    or

    print_r($AnswerResponse)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've this calling: $(document).ready(function () { $(#back).DynamicallyCentering({ Alignment: Vertical, Speed: 5 }); $(window).resize(function ()
is it possible to send back two parameters when calling a delegate method? I
I am calling a webservice and I am getting a complex object back. I
I am starting another activity by calling startActivityForResult() and after pressing back button my
I tried to encrypt an array then decrypt it back to string by calling
Calling image = Image.open(data) image.thumbnail((36,36), Image.NEAREST) will maintain the aspect ratio. But I need
Possible Duplicate: Spring's Stored Procedure - results coming back from procedure always empty. I
I am calling a giant stored proc via linq to sql that brings back
I was calling getJSON and looping through the results like this and everything was
Calling the WriteObject Method from a background thread is not possible! Is there a

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.