473,396 Members | 1,866 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,396 software developers and data experts.

Radio option null (not tached) value posting problem

19
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 1794
pbmods
5,821 Expert 4TB
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
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
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...
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: 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...
2
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...
4
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...
7
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...
8
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)...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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,...

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.