Jump to content

Recommended Posts

I'd like to generate a score from

this form. if someone selects 5 in qst 1. and 4 in qstn 2. it gets the sum automatically and saves in a mysql db.

 

 

Police/Military Service 5 4 3 2 1

5 = Infantry or Special Unit police or military

4 = Artillery or non-traffic police officer

3 = Tanks, military security forces or traffic police officer

2 = Air Force, naval service police staff

1 = Other military or police service (National Youth Service between 1996 and 1997)

 

Education 5 4 3 2 1

5 = Post graduate degree

4 = Undergraduate degree

3 = College, university non-degree

2 = Trade schools

1 = 0 Level or less

 

Age 5 4 3 2 1

5 = 25 to 45 years old

4 = 46 to 50 years old

3 = 20 to 24 years old

2 = 51 to 55 years old

1 = 56 and older

 

English Language 5 4 3 2 1

5 = Fluent speaking, writing and reading

4 = Fluent speaking and writing

3 = Fluent speaking

2 = Limited fluency speaking

1 = Marginal speaking

 

Leadership/Management 5 4 3 2 1

5 = Military or police officer ranks

4 = Military or police non-commissioned ranks

3 = Civilian executive

2 = Civilian managers/supervisors

1 = No management experience

 

Link to comment
https://forums.phpfreaks.com/topic/62813-solved-getting-the-sum/
Share on other sites

For the form tag: <form action='process.php' method='get'>

Then, in 'process.php', something like this:

 

<?php
$ans = Array($_GET['PoliceService'], $_GET['Education'], $_GET['Age'], $_GET['English'], $_GET['Leadership']);
$tot = array_sum($ans);

// Then...
$link = @mysql_connect("http://www.server.com", "username", "password");
if(!$link) die("Couldn't connect to the SQL server!");
mysql_select_db("results");
mysql_query("INSERT INTO survey VALUES ($tot)");
// etc...
?>

 

Hope that helps... if it doesn't please explain more what you want to do.

  • 4 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.