473,671 Members | 2,403 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Radio option null (not tached) value posting problem

19 New Member
Dear all,
I am new group user, computer science graduate; just have joined this established group and thanks to all. I am working in network field but so much interested in web (PHP) field. Recently i am dealling with an educational project like online exam (MCQ) and i am facing some problems for sending radio values to the submitted page.

Every question have 4 possible radio value. Questions are retrieved in the page by matching questions serial form a file and database table. After submission, correct answer is count by only matching the database correct value and selected radio value of each question. So when any user select all the questions correct or wrong way- then my calculation is fully ok. But if any user miss any question, I mean- not select any question then the calculation problem.

Here I feel that if any user doesn't select/ touch any question then that specific question will send a value like 'n' according to serial number, then this problem will be temporarily solved.

But here i think if the comparison is matched by both (serial and correct value vs Serial and users radio value) then the problem will solved efficiently. Here is My Sample code:

Users Question Page:
Expand|Select|Wrap|Line Numbers
  1. for ($i = 0 ; $i <= count($sl) ; $i++)
  2. {
  3. $sll=$sl[$i];
  4. $ql = "select * from table_questions where sl = '$sll' && subject='$subject' ";                
  5. $res = mysql_query($ql) or die(0);
  6. while ($row = mysql_fetch_array($res,MYSQL_BOTH))
  7. {
  8. $inp11=$inp11+1;
  9. $inp=$inp+1;
  10. $inp1="user_val[]".$inp;
  11.  
  12. print "<TR><TD><b>Q no.".$inp11.": ".$row['question']."</b></TD></TR>";                                
  13. print "<TR><TD><b><input type='radio' name='".$inp1."' value='a'> : </b>".$row['ans1']."</td></TR>";                        
  14. print "<TR><TD><b><input type='radio' name='".$inp1."' value='b'> : </b>".$row['ans2']."</td></TR>";
  15. print "<TR><TD><b><input type='radio'  name='".$inp1."' value='c'> : </b>".$row['ans3']."</td></TR>";
  16. print "<TR><TD><b><input type='radio'  name='".$inp1."' value='d'>  : </b>".$row['ans4']."</td></TR>";                
  17.  
  18. echo "<input type='hidden' name='db_val[]".$inp11."' value='".$row['correct']."'>";  
  19. echo "<input type='hidden' size=30 value='$inp11' name='qsl[$i]'>";  
  20. echo "<input type='hidden' size=30 value='$row[sl]' name='qsn[$i]'>";            
  21. }                    
  22. }
  23.  print "<input type ='hidden'  name='totalq' value='".$inp11."' >";
  24.  
  25. After submission:
  26.  
  27. $count=0;
  28. for($i=0; $i<$totalq; $i++)
  29. {
  30. if ($user_val[$i]==$db_val[$i])
  31. {
  32. $count+=1;
  33. }
  34. }
  35.  
Would you please give the real solution / modify the code? I am waiting for valuable solution.

Thanks to all
ahm
Oct 12 '07 #1
1 1802
pbmods
5,821 Recognized Expert Expert
Heya, ahmurad. Welcome to TSDN!

Please use CODE tags when posting source code:

[CODE=php]
PHP code goes here.
[/CODE]
Oct 12 '07 #2

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

Similar topics

1
4103
by: David | last post by:
Hi, May I know how to create data dynamically in a combo box after clicking on a radio button ? Data are retrieved using a store procedure from a SQL Server. For example : Click Radio Button 1, the combo box should contains "A", "B", "C" Click Radio Button 2, the combo box should contains "E", "F", "G"
1
6153
by: sman | last post by:
Hi, I recently read this article on About.com on how to create required fields for a form: http://javascript.about.com/library/scripts/blformvalidate.htm Everything works great except that there are no instructions on how to make checkboxes and radio buttons required. I've tried adding these to my form, but I'm having no luck. Anyone know how to add radio buttons and checkboxes using the existing code mentioned on the url? Thank you!
1
3408
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
11032
by: Jared | last post by:
Radio Button or Check Box and Event Procedures I need to insert either radio buttons or check boxes onto my form. I'm not sure which to use, or if there are other options. I am using the buttons to: if one is clicked, its corresponding information will become available on another document, if it's not clicked no information will be provided. If multiple buttons are clicked their information will available on the same document. I'm not...
2
3478
by: NishSF | last post by:
Would anyone have any suggestions/javascript code so that if one clicks the Radio Button "Yes" below he has the option of selecting any of the six CheckBox below. If the user clicks on Radio Button "No", he should not have the option of clicking on any of the six checkboxes. See Code attached. Thank you so much in advance for your help as I can't get to make this combo work. <p>Did you have any problems finding any of the information...
4
4558
by: Pasquale | last post by:
I am using the JS and HTML code below to check that required fields are completed for attributes of a product. The first attribute is a select menu and the second is a radio set. My JS goes through fine and detects if the select menu isn't selected with a value, but I keep getting 'undefined' for the radio element type. I've almost pulled out half a head of hair wondering why. Any experienced eyes see something I don't? Thanks, Pasquale
7
3522
by: Jerim79 | last post by:
My situation is that I have a form that asks the user for a number. Next, I execute a while loop that displays a group of questions the amount of times the customer entered. For instance, the loop looks this: while ($Number!=0){ <input type="radio" name="Age" value="20-30">20-30 <input type="radio name="Age" value="30-40">30-40 <input type="radio name"Age" value="40-50">40-50 $Number--;
8
4608
by: photoboy | last post by:
I have racked by brain long enough on this, so now I need the help of someone who knows what they are doing. Here is what I am trying to achieve: First, I have two radio buttons (both unchecked) that need to be validated when the submit button is clicked. Instead of the standard alert window popping up (which I have now), I want the radio button background color to change from the table color (E2E2E2) to red (FF0000) for both buttons...
0
8478
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8397
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8919
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8821
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7439
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4225
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2813
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
2
2052
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1810
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.