473,402 Members | 2,050 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,402 software developers and data experts.

How to calculate mark using check box

hello n gud day every one

basically my project is about personality test, it content 6 page of question which each page has 13 question

page 1
-----------------------

question 1 checkbox1
question 2 checkbox2
.
.
.
.
.
question 13 checkbox13
-------------------------------

once user click on next page, system will calculate number of checked check box and display the value on result page

and i having a problem to calculate number of checked checkbox in php.

i hope u guys can help me~

below is some of my code to retrieve data from dtbase

Expand|Select|Wrap|Line Numbers
  1.   <?php mysql_select_db("esci", $conn);
  2.         $result = mysql_query("SELECT * FROM personality_rule WHERE conclusion = 'Realistic'");    
  3.     while($data = mysql_fetch_array($result))
  4.       {
  5.     $rules = str_replace("_"," ",$data['question']);
  6.       echo'
  7.      <tr>
  8.      <td>'. $rules.'</td>
  9.      <td align="center"><input type="checkbox" name="ans"/></td>
  10.      </tr>
  11.      ';
  12.      }
  13.      ?>
Apr 6 '10 #1
2 2827
dlite922
1,584 Expert 1GB
since question - answer are pairs, you need something to tie those two together.

I can't get much from what you said or your code, but let's say you have a questions table. each question has an ID, and also a column perhaps if the question has finite set of answers. (i.e. A= Agree, B =Disagree, C = Don't care, etc)

You should store your answers in a another table that has that question ID and the value of the answer, be it an option, free text or a boolean Yes/No.

Your html input tag's name should somehow tie the answer to the question it answers.

for example:

Expand|Select|Wrap|Line Numbers
  1. <input type="radio" name="questionID_1" value=""/>
  2.  
  3. // or 
  4.  
  5. <input type="text" name="questionID_442" value="" /> 
  6.  
  7.  
Store the answer values in the session or in a table after each page, it's up to you.


Dan
Apr 6 '10 #2
@ dlite922

that is a good idea i never thought of doing it that simple...

thanks...
Apr 9 '10 #3

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

Similar topics

2
by: JP SIngh | last post by:
Hi All I need to calculate the number of working days between the two dates entered on an ASP page. I am not that great a coder in ASP and was wondering if someone can help. Basically the...
11
by: David | last post by:
I am learning plsql. I would like to run a stored procedure to calculate my bank account value by predicted 10% annual growth rate. Below is my plsql that is having problems. Your help is highly...
7
by: richard | last post by:
I have a table with 5 fields into which the user will enter numbers, which must add up to 100%. Say the fields are Toyotas, Missans, Mazdas, Hondas and Other. I am having trouble writing a query...
41
by: Saurabh Saxena | last post by:
can we calculate the 73! value in c or c++ without loss of significant digits.
6
by: charliewest | last post by:
Can someone pls point me to or recommend the easiest way to calculate someone´s age using the TimeSpan object, in .NET CF? Isn´t there a simple way to use the TimeSpan object to calculate the...
3
by: Al | last post by:
Hello, Sorry for the silly question: How do I insert Check Mark into RichTextBox? I can’t find the ascii code for it. Thanks Alex
12
by: paii, Ron | last post by:
Sorry about that last one. Does anyone know how to calculate the width a string of text for given Font name and size? I want to buildup a block of text strings to display in a unbound control,...
2
by: reidarT | last post by:
I have 3 fields in an aspx page. The 3. field should be the sum of field A and field B I use OnTextChanged to calculate the sum in field3. At the same time I want to insert the content of theese 3...
2
by: shah1711 | last post by:
Dear all, Can somebody help me, how to make access calculate result. I am helping my friends (he is a teacher). He want to get results for his students. e.g if the student get 80 % of total...
2
by: Mike | last post by:
Is there a way to calculate the total number of weekdays when provided a date? Example: If I have a start date of 7/11/2008 and I want to go out 10 days, I want to get this: 6 weekdays 4...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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.