miqyk Posted August 1, 2007 Share Posted August 1, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/62813-solved-getting-the-sum/ Share on other sites More sharing options...
RichardRotterdam Posted August 1, 2007 Share Posted August 1, 2007 sorry but what exactly do you want I don't have a clue on what you mean Quote Link to comment https://forums.phpfreaks.com/topic/62813-solved-getting-the-sum/#findComment-312835 Share on other sites More sharing options...
php_tom Posted August 7, 2007 Share Posted August 7, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/62813-solved-getting-the-sum/#findComment-317185 Share on other sites More sharing options...
miqyk Posted August 29, 2007 Author Share Posted August 29, 2007 thanks guys but i decided to use checkbox. its easy to do calculations with them than radio buttons. Quote Link to comment https://forums.phpfreaks.com/topic/62813-solved-getting-the-sum/#findComment-337031 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.