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 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.
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, 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...
|
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
|
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
|
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...
|
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...
| |
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'...
|
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...
|
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.
|
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
|
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...
|
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. ...
| |
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...
|
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
| |