In order to expand my php skill, I decided to work on a quiz. The initial format of my quiz was intended to work in the following manner:
I have my entire script set up using a switch. The default case is set to display a list of checkboxes:
<input type=\"checkbox\" name=\"q1" value=\"5\">
I want these checkboxes to pass the value parameter as an integer to the case that creates the score composite. At first, I tried adding up all the variables like so:
$composite = $q1 + $q2 + $q3; echo "Your compsite score is $composite out of 20.";
Instead, PHP echoed something similar to "Your score is out of 20." I then tried writing a while loop:
$pass = 0;
while ($pass != 9)
{
$q = "$" + "q$pass";
if (!$q)
{
echo "$q";
$composite = $composite + 0;
}
else
{
echo "$q";
$composite = $composite + $q;
}
$pass++;
}
I still cannot record the values from the value parameter. Can the value parameter be used like this, or is there another way I need to do this? Thanks in advance.