19Fermer21
juddhumLe 23/03/2007 à 15:04
"; } ?>Terminé... <h1>Qui pour 2007 ? (yAronet Edition)</h1> <?php $questions=array(                      array("Question 1",array("Rayponse 1","Réponse 2","Ruponse 3")),                      array("Question 2",array("Rzponse 1","Réponse 2","Réponse 3")),                      array("Question 3",array("Réponse 1","Réponse 2","Réponse 3")),                      array("Question 4",array("Réponse 1","Réponse 2","Réponse 3")),                      array("Question 5",array("Réponse 1","Réponse 2","Réponse 3")),                      array("Question 6",array("Réponse 1","Réponse 2","Réponse 3"))                 ); if(isset($_GET['action']) && $_GET['action']=="resultat") {      $reponses=array(                     array("Ximoon",1,2,3,1,2,3),                     array("montreuillois",3,2,1,3,2,1),                     array("vince",1,1,1,1,1,1),                     array("Budmilka",2,2,2,2,2,2),                     array("Rintintin",3,3,3,3,3,3)                );      echo "<h2>Résultats</h2>";      foreach($reponses as $r) $ressemblances[$r[0]]=0;      for($i=1 ; $i<=count($questions) ; $i++) {           for($j=1 ; $j<=count($reponses) ; $j++) {                if($reponses[($j-1)][$i]==(int)$_POST['q'.$i]) $ressemblances[$reponses[($j-1)][0]]+=1;           }      }      arsort($ressemblances);      echo "<h3>Vous ressemblez le plus à :</h3>";      echo "<ul>";      foreach ($ressemblances as $cle => $val) echo "<li><strong>".$cle." :</strong> ".round((($val/count($questions))*100),1)."%</li>";      echo "</ul>"; } else {      echo "<form method=\"post\" action=\"?action=resultat\">";      $i=0;      foreach($questions as $question) {           $i++;           echo "<div><strong>".htmlentities($question[0])."</strong>";           echo "<p>";           $j=0;           foreach($question[1] as $q) {                $j++;                echo "<input type=\"radio\" name=\"q".$i."\" value=\"".$j."\"> ".$q."<br />";           }           echo "</p>";           echo "</div>";      }      echo "<p><input type=\"submit\" value=\"Envoye euhl'questionnaire et file-moi l'résu\"></p>";      echo "</form>
Ne me manquent plus que quelques nouvelles questions.