Jump to content

PHP mySQL Quiz


Recommended Posts

Using Dreamweaver, php, mySQL

 

I have to make a quiz, with just 1 question and 1 answer.

 

Firstly I've created the database

Name: questionaire

Table: checkfyp

Fields: Question and Answer

 

The form only consist a question, and a textbox.

 

Connection from dreamweaver to mySQL is currently working. I could insert , delete, login and such stuffs.

 

I have no idea how to compare the user input with mySQL.

If correct -> /quiz/correct.php

else -> /quiz/incorrect.php

 

:ph34r: I'm a newbie in php..please help..

 

Link to comment
Share on other sites


<?php

// Connect to database


Put your database connect stuff here



// Quiz checking

$query = "SELECT * FROM checkfyp";
$result = mysql_query($query) or die(mysql_error());
while($r = mysql_fetch_array($result))
{

if($r[Question] == $user_submitted_Question)
{

Make page re-direction here to correct.php;

} else {


incorrect.php

}

}

?>

 

 

Hope you can understand this :(

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.