By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,661 Members | 781 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,661 IT Pros & Developers. It's quick & easy.

Retrieve saved data from database

P: 1
i have a project for online exam where we are providing tests in the following format
PAGE1
---------------
1.QUESTION
a.ans1
b.ans2
c.ans3
d.ans4
NEXT
------------------
on clicking the button "NEXT" it jumps to a second page with 2.QUESTION.i am not able to fetch the answer selected by the user to the user to PAGE 2 to calculate the score and display as YOUR SCORE: 0 OR 1
our work environment is ubuntu.
we are using PHP,and oracle database


my respective coding:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>Que1</title>
  4.  
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <link rel="stylesheet" type="text/css" href="rghtstyle.css" />
  7.  
  8.  
  9. </head>
  10. <body>
  11.       <div id="container">
  12.                 <div id="header">
  13.                         <h1><font size="22">HTN<span class="off">bench</span></font></h1>
  14.                         <h2></h2>
  15.         </div>
  16.  
  17. <form action="c2.php" method="post">
  18. <?php
  19. include('/usr/share/moodle/lib/adodb/adodb.inc.php');
  20. function InvokeErrorHandler(){
  21. global $db; ## assume global 
  22.         print_r($db->ErrorNo());
  23.         print_r($db->ErrorMsg());
  24. print_r("PHP to ORCALE error");
  25. }
  26. $db = NewADOConnection("oci8");
  27. if(!$db->connect('192.168.0.1:1521','htnbench','induzhtn','orcl')) InvokeErrorHandler();
  28. $rs =$db->Execute("select * from clang where quesno=1");
  29. ?>
  30. <?php
  31. while(!$rs->EOF){
  32. print_r($rs->fields[0].' '.$rs->fields[1].'<br>' );?>
  33. <?php 
  34. $a=$rs->fields[2];
  35. $b= $rs->fields[3];
  36. $c=$rs->fields[4];
  37. $d=$rs->fields[5];
  38. ?>
  39. <p>
  40.         <input type="radio" name="ans" value=""/> <?php print_r($a.'<br>' ); ?>
  41. <p>
  42.         <input type="radio" name="ans" value=""/> <?php print_r($b.'<br>' ); ?>
  43. <p>
  44.         <input type="radio" name="ans" value=""/> <?php print_r($c.'<br>' ); ?>
  45. <p>
  46.         <input type="radio" name="ans" value=""/> <?php print_r($d.'<br>' ); ?>
  47.  
  48. <?php
  49. $rs->MoveNext();
  50. echo "<hr>";
  51. }?>
  52. <center><input name="" type="submit" value="Next" /></center>
  53. </form>
  54. </body>
  55. </html>
Oct 12 '11 #1
Share this Question
Share on Google+
2 Replies


Rabbit
Expert Mod 10K+
P: 12,364
Your radio buttons have no values so it's not going to pass anything.
Oct 12 '11 #2

P: 59
onselect of the answer is the form submitted if so u can collect the option selected to a table that relates questions to option the user selected before u load the new question
Oct 13 '11 #3

Post your reply

Sign in to post your reply or Sign up for a free account.