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. -
<html>
-
<head><title>examination</title></head>
-
<body>
-
-
<?php
-
-
$mins = date("i");
-
-
if ($mins >= 0 && $mins < 30)
-
{
-
$timestr = date("H").':30';
-
}
-
else
-
{
-
$hour = (date("H") == 23) ? 00 : date("H")+1;
-
$timestr = $hour.':00';
-
}
-
-
$timeleft = strtotime($timestr) - time();
-
-
?>
-
-
<script type="text/javascript">
-
var timeleft = <?php print $timeleft; ?>;
-
window.onload = function() {
-
timer = setInterval(function() {
-
timeleft = (timeleft == 0) ? 1800 : timeleft-1;
-
document.getElementById('timeleft').innerHTML = timeleft;
-
}, 1000);
-
}
-
</script>
-
-
<span id="timeleft"><?php echo $timeleft; ?></span> seconds left
-
<?php
-
error_reporting('E_ALL ^ E_NOTICE');
-
mysql_connect('localhost','root','') or die(mysql_error());
-
mysql_select_db('test') or die(mysql_error());
-
$page=$_REQUEST['p'];
-
$limit=2;
-
if($page=='')
-
{
-
$page=1;
-
$start=0;
-
}
-
else
-
{
-
$start=$limit*($page-1);
-
}
-
-
$query=mysql_query("select * from history limit $start, $limit") or die(mysql_error());
-
$tot=mysql_query("select * from history") or die(mysql_error());
-
$total=mysql_num_rows($tot);
-
$num_page=ceil($total/$limit);
-
?>
-
<form name="exam">
-
<table><h2>Quiz</h2>
-
<?php while($res=mysql_fetch_array($query))
-
{ ?>
-
<tr><td>Q<?php echo $res['id']?>. <?php echo $res['question'] ?></td></tr>
-
<tr><td><input type="radio" id="a" name="ans" value="a">a.<?php echo $res['a']?></td></tr>
-
<tr><td><input type="radio" id="b" name="ans" value="b">b.<?php echo $res['b']?></td></tr>
-
<tr><td><input type="radio" id="c" name="ans" value="c">c.<?php echo $res['c']?></td></tr>
-
<tr><td><input type="radio" id="d" name="ans" value="d">d.<?php echo $res['d'] ?><br><br></td></tr>
-
-
<?php } ?>
-
</table>
-
<?php
-
function pagination($page,$num_page)
-
{
-
echo'<ul style="list-style-type:none;">';
-
for($i=1;$i<=$num_page;$i++)
-
{
-
if($i==$page)
-
{
-
echo'<li style="float:left;padding:5px;">'.$i.'</li>';
-
}
-
else
-
{
-
echo'<li style="float:left;padding:5px;"><a href="pagination.php?p='.$i.'">'.$i.'</a></li>';
-
}
-
}
-
echo'</ul>';
-
}
-
if($num_page>1)
-
{
-
pagination($page,$num_page);
-
}
-
?>
-
<input type="submit" value="Submit Quiz"></input>
-
</form>
-
-
</body>
-
</html>
-
-
-
1 4255
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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,...
|
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...
|
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...
|
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,...
|
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...
|
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...
|
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)...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
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
|
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...
|
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...
| |