ciao a tutti, ho creato 12 domande a scelta multipla.
Per mostrare il risultato ho utilizzato questo codice :
entra nel primo if quando clicco sul bottone submit.codice:if (isset($_POST['submit'])) { $a=0; $b=0; $c=0; //prima domanda if ($_POST['domanda_1'] == "a") { $a++; } if ($_POST['domanda_1'] == "b") { $b++; } if ($_POST['domanda_1'] == "c") { $c++; } //seconda domanda if ($_POST['domanda_2'] == "a") { $a++; } if ($_POST['domanda_2'] == "b") { $b++; } if ($_POST['domanda_2'] == "c") { $c++; } //terza domanda if ($_POST['domanda_3'] == "a") { $a++; } if ($_POST['domanda_3'] == "b") { $b++; } if ($_POST['domanda_3'] == "c") { $c++; } //quarta domanda if ($_POST['domanda_4'] == "a") { $a++; } if ($_POST['domanda_4'] == "b") { $b++; } if ($_POST['domanda_4'] == "c") { $c++; } //quinta domanda if ($_POST['domanda_5'] == "a") { $a++; } if ($_POST['domanda_5'] == "b") { $b++; } if ($_POST['domanda_5'] == "c") { $c++; } //sesta domanda if ($_POST['domanda_6'] == "a") { $a++; } if ($_POST['domanda_6'] == "b") { $b++; } if ($_POST['domanda_6'] == "c") { $c++; } //settima domanda if ($_POST['domanda_7'] == "a") { $a++; } if ($_POST['domanda_7'] == "b") { $b++; } if ($_POST['domanda_7'] == "c") { $c++; } //ottava domanda if ($_POST['domanda_8'] == "a") { $a++; } if ($_POST['domanda_8'] == "b") { $b++; } if ($_POST['domanda_8'] == "c") { $c++; } //nona domanda if ($_POST['domanda_9'] == "a") { $a++; } if ($_POST['domanda_9'] == "b") { $b++; } if ($_POST['domanda_9'] == "c") { $c++; } //decima domanda if ($_POST['domanda_10'] == "a") { $a++; } if ($_POST['domanda_10'] == "b") { $b++; } if ($_POST['domanda_10'] == "c") { $c++; } //undicesima domanda if ($_POST['domanda_11'] == "a") { $a++; } if ($_POST['domanda_11'] == "b") { $b++; } if ($_POST['domanda_11'] == "c") { $c++; } //dodicesima domanda if ($_POST['domanda_12'] == "a") { $a++; } if ($_POST['domanda_12'] == "b") { $b++; } if ($_POST['domanda_12'] == "c") { $c++; } $massimo = max($a,$b,$c); switch ($massimo) { case $a: echo "profilo A"; break; case $b: echo "profilo B"; break; case $c: echo "profilo C"; break; } } ?>
Il problema è che i profili per la maggior parte mi vengono sballati.
Ovvero anche se seleziono tutte b alle volte compare come risultato il profilo A.
Sapreste spiegarmi dove sbaglio??

Rispondi quotando