Need help with php quiz script

monkey

New Member
Hello everyone,

I'm new to this forum and hope that someone can help me. :confused::(
I'm trying to write a little quiz for my website, but I'm stuck with displaying the results.
Questions and answers are in a Mysql database and below is the script to display the questions and the answers are with radio buttons.
By clicking the 'finish' button it should go to 'test.php' where it should display the answers the test candidate chose with the question and then the correct answer next to it (or below).
I just can't get to it though.
I'd appreciate a little nodge into the right direction on how to get the test.php to display the answers.

Thanks so much for all the help and redirecting

Monkey

The code for questions.php is this one:
PHP:
   6. <?php
   7. // Connects to your Database
   8.  $dbh=mysql_connect ("localhost", "webxxxx", "password") or die ('I cannot connect to the database because: ' . mysql_error());
   9. mysql_select_db ("webxxxx");
  10.  
  11. //Writes the information to the database
  12. $data = mysql_query("SELECT * FROM table") or die(mysql_error());
  13.  
  14. //Puts it into an array
  15. while($info = mysql_fetch_array( $data ))
  16. {
  17. ?>
  20. <br>
  21. <form method="get" action="test.php" name="test">
  22.   <font size="2" face="Verdana, Arial, Helvetica, sans-serif">
  28.       <?php
  29. //Outputs the image and other data
  30. Echo "<b>".$info['ID'] .  "</b> ".$info['question'] . "<br/> ";?></strong></p></font>
  31. <blockquote>
  32.           <p> <font size="2" face="Verdana, Arial, Helvetica, sans-serif"> # <?php
# Echo "<input type='radio' name=".$info['ID'] ." value=".$info['a1'] . " \n"; echo ">".$info['a1'] . " <br/>";
# Echo "<input type='radio' name=".$info['ID'] ." value=".$info['a2'] . " \n"; echo ">".$info['a2'] . " <br/>";
# Echo "<input type='radio' name=".$info['ID'] ." value=".$info['a3'] . " \n"; echo ">".$info['a3'] . " <br/>";
# Echo "<input type='radio' name=".$info['ID'] ." value=".$info['a4'] . " \n"; echo ">".$info['a4'] . " <br/>"; 
  37.  
  38. ?> </font></p>
  39.         </blockquote>
  40.   <?php }?>
  52. <input type="submit" name="submit" value="Finished!">
  53.         </font></td>
  54.     </tr>
  55.   </table>
  56.  
  57.  
  58.   <br>
  59. </form>

And this is what I've got so far for the test.php

PHP:
   1. $query = "SELECT * FROM test WHERE ID=\"{$_GET[$info['ID'] ]}\" ";
   2. $result = mysql_query("SELECT * FROM test WHERE ID=\"{$_GET[$info['ID'] ]}\" ") or die ("couldn't execute query.");
   3. while($row = mysql_fetch_assoc($result))
   4. {
   5. Echo "<b>".$row['ID'] . "</b> echo ".$row['question'] . "<br/> ";
   6. }

But it jut displays a blank page. :(:confused:

Thank you all very much for helping!!

Monkey
 
Top