I have some code that is grading answers users put in using radio buttons. I have a particular question where no matter what they put in the radio buttons they could receive some credit. In other words there are no incorrect answers but many multiple choices the user could use to receive credit. My question is how could I write this code to insert a certain value into mySQL if they user selects 3 out of the five possible values no matter what the values are? Right now I am writing code that is allowing for all the individual choices and it is becoming a huge long list of code. This is what I am using now.
if (($calc1 == "answer1") && ($calc2 =="answer2") && ($calc3 =="answer3")
&& ($calc4 =="") && ($calc5 ==""))
{
mysql_query("UPDATE testfour set questiontwo = $numfive WHERE id = $session[id]");
}
//then I would have to write the next line like this...
else if (($calc1 == "answer1") && ($calc2 =="answer2") && ($calc3 =="")
&& ($calc4 =="answer4") && ($calc5 ==""))
{
mysql_query("UPDATE testfour set questiontwo = $numfive WHERE id = $session[id]");
}
//and so on until all the possible variations of three choices are made. Wouldn't it be easier to just tell mySQL to insert a variable if the user chooses three answers no matter what those three answers are?
thanks,
Justin