473,320 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

how to use radio button in online examination system.

in my project i have designed a online examination system
i have using one question and 4 options as a,b,c,d.i fetch the questions from database how to use this radio buttons dynamically to all questioned options(a,b,c,d).in my code i select one radio button it selected after that i click another one questioned option (radio button)its diabled.how to use radio button commonly for all questions in php. my code is here.

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head><title>examination</title></head>
  3. <body>
  4.  
  5. <?php
  6.  
  7. $mins = date("i");
  8.  
  9. if ($mins >= 0 && $mins < 30)
  10. {
  11.     $timestr = date("H").':30';
  12. }
  13. else
  14. {
  15.     $hour = (date("H") == 23) ? 00 : date("H")+1;
  16.     $timestr = $hour.':00';
  17. }
  18.  
  19. $timeleft = strtotime($timestr) - time();
  20.  
  21. ?>
  22.  
  23. <script type="text/javascript">
  24. var timeleft = <?php print $timeleft; ?>;
  25. window.onload = function() {
  26.     timer = setInterval(function() {
  27.         timeleft = (timeleft == 0) ? 1800 : timeleft-1;
  28.         document.getElementById('timeleft').innerHTML = timeleft;
  29.     }, 1000);
  30. }
  31. </script>
  32.  
  33. <span id="timeleft"><?php echo $timeleft; ?></span> seconds left
  34. <?php
  35. error_reporting('E_ALL ^ E_NOTICE');
  36. mysql_connect('localhost','root','')  or die(mysql_error());
  37. mysql_select_db('test')  or die(mysql_error());
  38. $page=$_REQUEST['p'];
  39. $limit=2;
  40. if($page=='')
  41. {
  42.  $page=1;
  43.  $start=0;
  44. }
  45. else
  46. {
  47.  $start=$limit*($page-1);
  48. }
  49.  
  50. $query=mysql_query("select * from history limit $start, $limit") or die(mysql_error());
  51. $tot=mysql_query("select * from history") or die(mysql_error());
  52. $total=mysql_num_rows($tot);
  53. $num_page=ceil($total/$limit);
  54. ?>
  55. <form name="exam">
  56. <table><h2>Quiz</h2>
  57. <?php while($res=mysql_fetch_array($query))
  58. { ?> 
  59.   <tr><td>Q<?php echo $res['id']?>.&nbsp;<?php echo $res['question'] ?></td></tr>
  60.   <tr><td><input type="radio" id="a" name="ans" value="a">a.<?php echo $res['a']?></td></tr>
  61.   <tr><td><input type="radio" id="b" name="ans" value="b">b.<?php echo $res['b']?></td></tr>
  62.   <tr><td><input type="radio" id="c" name="ans" value="c">c.<?php echo $res['c']?></td></tr>
  63.   <tr><td><input type="radio" id="d" name="ans" value="d">d.<?php echo $res['d'] ?><br><br></td></tr>
  64.  
  65. <?php } ?>
  66. </table>
  67. <?php
  68. function pagination($page,$num_page)
  69. {
  70.   echo'<ul style="list-style-type:none;">';
  71.   for($i=1;$i<=$num_page;$i++)
  72.   {
  73.      if($i==$page)
  74. {
  75.  echo'<li style="float:left;padding:5px;">'.$i.'</li>';
  76. }
  77. else
  78. {
  79.  echo'<li style="float:left;padding:5px;"><a href="pagination.php?p='.$i.'">'.$i.'</a></li>';
  80. }
  81.   }
  82.   echo'</ul>';
  83. }
  84. if($num_page>1)
  85. {
  86.  pagination($page,$num_page);
  87. }
  88. ?> 
  89. <input type="submit" value="Submit Quiz"></input>
  90. </form>
  91.  
  92. </body>
  93. </html>
  94.  
  95.  
  96.  
Aug 7 '14 #1
1 4255
Dormilich
8,658 Expert Mod 8TB
each group of buttons (a, b, c, d) needs its own unique name. i.e. the radio buttons from question 1 need a different name from question 2’s buttons.
Aug 8 '14 #2

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

Similar topics

4
by: mir nazim | last post by:
hi there, One of my client needs a computer based examination system. It should have following capabilities. 1. It should support Multiple choice questions. 2. It should be adaptive, that is,...
1
by: MickG | last post by:
I am trying to change the value of the variable "hard" according to which radio button is pressed and I am having no joy. Could anyone help me with this, the problematic section is marked with...
4
by: Hazzard | last post by:
What is the best way to do this? Binary with 0 representing off and 1 on? Int16 with 1 representing first button, 2 the second, 3 ... varchar with a character values at certain positions in the...
3
by: John Davis | last post by:
I created a ASP.NET Web Form using VB.NET with a text box, 2 radio buttons. When the user click the first radio button, the text will change to uppercase. If the user clicks the other radio button,...
0
by: vinay | last post by:
why are u not using the radiobutton list??? vinay >-----Original Message----- >I created a simple ASP.NET application with a text field, and 2 radio >buttons (uppercase and lowercase...
16
by: Vikas Kumar | last post by:
i am selectin some data from database and through reader showing it in datalist as above now for radio buttons i have single column which returns 1,2,3 and according to that i want one of above...
2
by: newfie912 | last post by:
I have an online application used for grading students. On one of the pages, I have a table with two rows and each row has 16 cells. The upper row contains the letter grade (A, A-, B+, B, etc)...
1
by: rajat0902 | last post by:
im working on an online examination system.we have three options for examinations.various questions on each topic,provision for a timer,and negative marking sceme.please give me some ideas for the...
2
by: kkshansid | last post by:
can anyone suggest free and secure php script for online examination system for students? i searched on google and i found some bt they were for limited time period like tcexam for 30 days i am new...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.