473,569 Members | 2,845 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to calculate mark using check box

1 New Member
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 2834
dlite922
1,584 Recognized Expert Top Contributor
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
MusoFreak200
96 New Member
@ 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
4732
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 form has Two textboxes to enter dates From Date - Fdate To Date - TDate
11
7776
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 appreciated. Thanks declare money number := 50000.00; year number := 1;
7
1815
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 using Sum which will add these together and place the result in another field called "total" which I will then place on a form so the user can check...
41
3065
by: Saurabh Saxena | last post by:
can we calculate the 73! value in c or c++ without loss of significant digits.
6
31783
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 elapsed time and somehow convert the days to years w/out using the VB DLL? Thanks.
3
32307
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
14469
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, that has limited width but multiple lines. Currently I am using the left$() function to trim the text to a standard number of characters. I want a...
2
1542
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 fields into a row in a table. The problem is that I need 'postback is true' on the textfields to get an immediate calculation and then the insert...
2
1521
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 mark, he will got "A". if the student get 40 % of the total mark, he will got "D" if the student get below 40%, he will get "FAIL". shah
2
1944
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 weekend days
0
7612
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...
0
7922
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. ...
0
8119
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...
0
6281
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...
0
5218
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...
0
3653
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...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2111
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
0
936
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...

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.