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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:27:51+00:00 2026-06-18T06:27:51+00:00

I am currently building an multiple choice quiz module for my website. There is

  • 0

I am currently building an multiple choice quiz module for my website. There is a list with 20 questions, which can only be answered by customers that are logged in.

I have three tables:

table questions, with fields questions.id, questions.description

table options, with fields options.id, options.questionid, options.trueorfalse

table answers, with fields answers.id, answers.customerid, answers.questionid, answers.chosenoption

The questions come at random, rand(), by an ajax-call, so only the questions that are not answered by a customer are being showed. Once all questions are answered, the final score is echoed.

Can someone help me with the correct sql statement the php script should run to show up the questions that have NOT been answered by a customer?

Currently it seems to work but I sometimes have to submit twice the same answer. Actually the first time it is aleady being sent, but the ajax call shows up the same question.

This is the sql statement I use…

SELECT * from questions
where  not exists (
select answers.questionid from answers
where answers.questionid = questions.id 
and answers.customerid = '".$customerid."' )
order by rand()
limit 1"

The data is being sent by a JQuery post (works well).
Inside the page quiz_ajax.php

<script type="text/javascript">
$(document).ready(function(){
$("#ajax-post-answer").submit(function(){
var str = $(this).serialize();
$.ajax({
type: "POST",
url: "answerpost.php",
data: str
 });

callquiz();

return false;
});
});
</script>

Inside the page quiz.php (main page)

<script type="text/javascript"> 
function callquiz()
{
var newDate = new Date;
$.ajax({
method: 'POST',
url : 'quiz_ajax.php?'  + newDate.getTime(),
dataType : 'text',
success: function (text) { 
$('#updateMequiz').html(text); }
});
}

callquiz();
</script> 
<div id="updateMequiz"></div>

So the function callquiz, should refresh this div with a new question. I am investigating this problem for 24 hours now, so I am very curious to hear what I am doing wrong.

Thanks in advance!!

  • 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-18T06:27:53+00:00Added an answer on June 18, 2026 at 6:27 am

    The issue is likely related to the asynchronous nature of HTTP/AJAX: just because the request has been “put on the wire” does not mean it has actually been processed by the server – much less saved to the database!

    As a quick check, move callquiz() from the $.submit callback to the success callback of the “answerpost.php” $.ajaxcallback. (That is, only request new information after the completion of the request that submits question answers.)

    This will ensure that the “update” (answerpost.php) operation has occurred (and completed) before the next “get quiz” (quiz_ajax.php) request. If this is indeed the case, consider having the “update” also return the “get quiz” information to make a single unified call.

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

Sidebar

Related Questions

I am currently building a website with multiple pages and in order to beautify
I'm building a CLI survey app in Java that lets users answer multiple-choice questions.
I have a web app I am building that has primarily multiple choice questions
I am currently building a questionnaire system which spans over multiple steps (pages). I
I'm building a Chrome extension, which uses multiple APIs. Currently I have it set
We're currently building multiple copies of our Chrome CRX, one for each of our
I'm currently building a website with Django and want to host user bio style
I'm currently building a website (ASP.net c#) and we're looking at creating a live
I'm currently building a multiple-document interface application, but I'm having a problem when the
Currently building a Rails 3 app and I've notice there are a lot of

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.