473,549 Members | 3,109 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to use radio button in online examination system.

9 New Member
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 4291
Dormilich
8,658 Recognized Expert Moderator Expert
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
3996
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, difficulty should vary with each question. kind of those used in MCSD/MCSE/SCJP etc examinations. 3. should be web based. 4. MySQL support. (better...
1
3374
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 ***********************, I've included all the code incase that isn't where the problem is. Any help would be hugely appreciated. Mick
4
9879
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 string representing radio button values. Thanks, -hazz
3
3110
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, the text will change to lowercase. I added the following event, but still won't able to change the text to uppercase. Private Sub...
0
1799
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 conversion). When the user enters a text in >text field, the user can click the radio button for case conversion. I set >the property of radio button to...
16
12135
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 radio button to be preselected in this datalist how can i do that doing something like this but this gives error "The type or namespace name 'rdbtn'...
2
2608
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) and the lower row has a 16 radio buttons for selecting the appropriate grade. This all writes to a SQL server back-end and has been working fine for...
1
3570
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 same as early as possible. thanking you.
2
4261
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 to php and someone told me everything is free in php your suggestions will be very helpfull to me thanx in advance
0
7446
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7718
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7809
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6041
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5368
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5088
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3498
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3480
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1936
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.