I am trying to make a PhP color code test and I can not get it just right. Right now all I can get it to do is post the value. How I want it to work is:
There is 4 questions (on my real test there will be 45) with 4 different options to choose from. I would like the PhP to be able to determine which option was chosen for each question then assign a value to the option so in the end of the test it will be able to add each individual option for each question together… Example:
Q1 proactive nurturing objective insightful
Q2 indecisive arrogant a perfectionist poor follow-through
Q3 enthusiastic kind caring productive
Q4 relentless suspicious indifferent naive
Peron takes test and for Q1 chooses “proactive” then on Q2 chooses “indecisive” Q3 chooses “kind” Q4 chooses “naive”
I want the results to show as Reds (or column 1)=2
Blues (or Column 2) =1
Yellows (or Column 3)=0
White (or Column 4)=1
Here is a sample of my code that I have already wrote.
<?php
function add($a =0, $b = 0, $c =0, $d =0)
{
return ($a + $b + $c + $d);
}
$r1 = $_POST[‘r1’];
$r2 = $
$r3 = $_POST[‘r3’];
$r4 = $
?>
<form action=”results.php” method=”post”>
<table>
<tr>
<li><ul>
<td><label title=”Definition: Acting positive, pre-emptive in resolving problems”><input TYPE=”radio” VALUE=”1″ NAME=”r1″> proactive</label></td>
<td><label title=”Definition: Caring, concerned, attentive”><input TYPE=”radio” VALUE=”1″ NAME=”r1″> nurturing</label></td>
<td><label title=”Definition: Displaying clear and unbiased judgment, fair”><input TYPE=”radio” VALUE=”1″ NAME=”r1″> objective</label></td>
<td><label title=”Definition: Being perceptive of subtle ideas or concepts”><input TYPE=”radio” VALUE=”1″ NAME=”r1″> insightful</label></td>
</ul></li>
</tr>
</table>
<table><tr>
<li> <ul>
<td><label title=”Definition: Uncertain, hesitant, ambivalent”><input TYPE=”radio” VALUE=”1″ NAME=”r2″> indecisive</label></td>
<td><label title=”Definition: Puffed up, conceited, air of superiority”><input TYPE=”radio” VALUE=”1″ NAME=”r2″> arrogant</label></td>
<td><label title=”Definition: Insistent on eliminating all flaws and error”><input TYPE=”radio” VALUE=”1″ NAME=”r2″> a perfectionist</label></td>
<td><label title=”Definition: Not seeing things through to the end”><input TYPE=”radio” VALUE=”1″ NAME=”r2″> poor follow-through</label></td>
</ul></li>
</tr></table>
<table><tr>
<li> <ul>
<td><label title=”Definition: Eager, spirited, energetic”><input TYPE=”radio” VALUE=”1″ NAME=”r3″> enthusiastic</label></td>
<td><label title=”Definition: Gentle, pleasant, considerate”><input TYPE=”radio” VALUE=”1″ NAME=”r3″> kind</label></td>
<td><label title=”Definition: Feeling and exhibiting concern and empathy for others”><input TYPE=”radio” VALUE=”1″ NAME=”r3″> caring</label></td>
<td><label title=”Definition: Efficient, resourceful, constructive”><input TYPE=”radio” VALUE=”1″ NAME=”r3″> productive</label></td>
</ul></li>
</tr></table>
<table><tr>
<li> <ul>
<td><label title=”Definition: Unyielding in severity or strictness”><input TYPE=”radio” VALUE=”1″ NAME=”r4″> relentless</label></td>
<td><label title=”Definition: Distrustful, skeptical, wary”><input TYPE=”radio” VALUE=”1″ NAME=”r4″> suspicious</label></td>
<td><label title=”Definition: Apathetic, emotionally detached”><input TYPE=”radio” VALUE=”1″ NAME=”r4″> indifferent</label></td>
<td><label title=”Definition: Trusting, gullible, unsuspecting”><input TYPE=”radio” VALUE=”1″ NAME=”r4″> naïve</label></td>
</ul></li>
</tr></table>
<input type=”submit” value=”Calculate values”/>
</form>
Answer : <?php echo add($r1,$r2,$r3,$r4); ?>
Right now it only adds all the columns together so I can not separate out the Columns and tell people what there answer are.
I am sorry this is so long. If this does not make sense please let me know and I will try to explain it better.
Please and thank you for any help