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

  • Home
  • SEARCH
  • 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 8919077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:55:28+00:00 2026-06-15T05:55:28+00:00

I am using the following with a quiz I am making, it checks the

  • 0

I am using the following with a quiz I am making, it checks the table to see if the user has already posted the answer to the question and isn’t hammering the submit button, the problem I am having is its not posting the info to the database for some odd reason. If I take out the if statement and the first database looking and just post the data it works fine, but when I check the result of the first query first, it doesn’t appear to work, even if the user hasn’t submitted an answer yet.

 <?php
 $quizID = $_GET['quiz'];
$userID = $_GET['user'];
$quizselectanswer = $_POST['quizselectanswer'];
$cf_created = date("y/m/d");
$questionID = $_POST['questionID'];

// Check to see if user answered question already
 $result = mysql_query("SELECT questionID,userID FROM itsnb_chronoforms_data_answerquiz WHERE     questionID='$questionID' AND userID='$userID' LIMIT 1") or die(mysql_error());

while($row = mysql_fetch_array($result))
{ 
if (empty($row))
{
    mysql_query("INSERT INTO itsnb_chronoforms_data_answerquiz (cf_created,     questionID,quizselectanswer,quizID, userID)
    VALUES ('$cf_created', '$questionID', '$quizselectanswer', '$quizID','$userID')") 
    or     
    die(mysql_error());
}else{

}
}
?>

My database looks like this itsnb_chronoforms_data_answerquiz cf_id, cf_uid, cf_created, cf_modified ,cf_ipaddress ,cf_user_id ,questionID, quizselectanswer, quizID ,userID.

  • 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-15T05:55:30+00:00Added an answer on June 15, 2026 at 5:55 am

    Try like this it may help you

    // Check to see if user answered question already
     $result = mysql_query("SELECT * FROM itsnb_chronoforms_data_answerquiz WHERE questionID='$questionID' AND userID='$userID' LIMIT 1") or die(mysql_error());
    
    $row = mysql_fetch_array($result);
    if(!empty($row)) 
    {
        while($row){
            //some statement
        }
    }else{
        mysql_query('INSERT INTO itsnb_chronoforms_data_answerquiz (cf_created, questionID,quizselectanswer, quizID, userID)
        VALUES ("'.$cf_created.'", "'.$questionID.'", "'.$quizselectanswer.'", "'.$quizID.'","'.$userID.'")') or die(mysql_error());
    }
    ?>
    

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

Sidebar

Related Questions

I using following code: var search = 'test'; if ($('#sku').find(search) ){ //alert(search); $(document).find(search).css('color','red'); <TABLE>
I am using following query to bulk insert from one table to another. INSERT
afternoon, I am using the following countdown for a quiz app i am writing.
I have the following tables for a php mysql based quiz application: QUESTION id
Quiz: what does the following program print? using System; using System.Runtime.InteropServices; namespace ConsoleApplication2 {
I am trying to make a quiz and am using the following to compare
I am using the following script to check a code, so when the user
Using following code I try to get updated list of checkbuttons' corresponding text values,
I am creating date using following code try { newdatetime = new DateTime(2012, 2,
I am using following configuration to properly fit image inside a scrollview. <?xml version=1.0

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.