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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:17:15+00:00 2026-06-14T20:17:15+00:00

I am trying to make a quiz using PHP and Mysql. I have create

  • 0

I am trying to make a quiz using PHP and Mysql. I have create my database and filled it. The database is construct as follows: question_id(P.K),question, right answer, annswer1,answer2, answer3,level and test_id(F.K).

I have created a query that “draws” questions in a random order and I have shuffled the answers. The PHP script for showing the Qs and As to the user is the following:

while ($index <= (count($test)-1)){
 echo $test[$index]['question']. "<br/>";
 $question_id=$test[$index]['question_id'];
 $s_ans=User_Model::shuffle_answers($question_id);
  foreach ($s_ans as $s_a){
      echo "<input type='radio' name='test_ans[$index][$s_a]' id='$question_id' />$s_a <br />";

      }

 echo "<hr/>";
      $index++;

  }

The above code shows all questions and their answers at once.
What I would like to do, and couldn’t successfully get it done, is to show each question separately and when the user presses the “next” button, the next question accompanied by its answers will be shown to him.

So,

a)is there a way I can achieve that?

b)when I try to access user’s answers I get the following output:

Array ( [0] => Array ( [I  like ice cream => on ) [1] => Array ( [i don't go to school] => on ) [2] => Array ( [i play basketball] => on ) [3] => Array ( [i like sailing] => on ) )

How can i access the user’s answers as to compare them with the right answer?

  • 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-14T20:17:17+00:00Added an answer on June 14, 2026 at 8:17 pm

    Multipage quizzes are very easy to do.

    A) This can be done by removing the while() loop, but leave the counter to pass through a hidden <input> OR increasing the $_SESSION variable

    $index = $_POST['index'] // OR $_GET['index'] OR $_SESSION['index'] depending on your form method
    echo $test[$index]['question']. "<br/>";
    $question_id=$test[$index]['question_id'];
    $s_ans=User_Model::shuffle_answers($question_id);
    foreach ($s_ans as $s_a){
      echo "<input type='radio' name='test_ans[$index][$s_a]' id='$question_id' />$s_a <br />";
    }
    
    if ($index < $total_questions){
    $index++; // Increase var, and then use in hidden input
    echo "<input type='hidden' name='index' value='$index' />";
    echo "<input type='submit' name='submit_answer' value='Next' />";}
    else {
    echo "<input type='submit' name='submit_answer' value='You Are Done' />";}
    //OR
    $_SESSION['index'] = $index++;
    

    B) Without your code, this is just an example –

    if ($user[$index]['their answer'] == $test[$index]['right answer'])
       { echo "You were correct";}
    else
       { echo "Sorry, your answer was incorrect";}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make a simple quiz with just one question, I have
I'm trying to make a simple three question quiz in php. After the user
I have the following tables for a php mysql based quiz application: QUESTION id
Good day. I'm trying to make an online quiz application using php. The idea
I'm trying to grade a quiz application I would like to make. I have
Right now I'm trying make some browser based game. But I have little questions.
I am trying to make a quiz and am using the following to compare
I'm trying to make a quiz application and I need to retrieve n number
I am trying to make a quiz app, so there are 5 radio buttons
Im trying to make multiple quizes that will keep track of each quiz on

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.