Page 1 of 1

mutiple choice calculations

Posted: Tue Aug 01, 2006 10:33 am
by dandare
hi there,

I was wondering if anyone had any ideas of how I can represent a correct answer asw a number which will be calculated and sent back via the feedback page

Code: Select all

echo "<p><input type=radio name=Q1 value=\"$aa\">$aa<br /> 
                <input type=radio name=Q1 value=\"$ab\">$ab<br /> 
	        <input type=radio name=Q1 value=\"$ac\">$ac<br /> 
	        <input type=radio name=Q1 value=\"$ad\">$ad<br /></p>";
Is it possible to use a condition such as:


Code: Select all

if($aa = $Q1) {
$Q1 == 1; 
}else{ 
$Q1 == 0;
or something similar?



Any feedback would be appreciated.
Thank you

Posted: Tue Aug 01, 2006 10:44 am
by feyd
use a switch.

Posted: Tue Aug 01, 2006 11:09 am
by dandare
Hi Feyd

Thanks for you feedback. Just a little clarity (I think i worte my php out wrong).

By posting a form it reads the name and takes the value. As answer A ($aa) is the correct value should i say:

Code: Select all

switch ($Q1) {

case '$aa' : ==1;
break;

case '$ab' ==0;
etc..
sorry i'm kinda new to this