Jump to content


Photo

PHP mySQL Quiz


  • Please log in to reply
1 reply to this topic

#1 iamnoob

iamnoob
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 25 March 2004 - 02:26 AM

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..


#2 PHP Monkeh

PHP Monkeh
  • Members
  • PipPipPip
  • Advanced Member
  • 409 posts
  • LocationUnited Kingdom

Posted 25 March 2004 - 03:07 PM


<?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 :(
No monkey business
[br]Remember the manual PHP.net
Legacy Design




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users