connect (); //what question is this? $count = $_POST['count']; $correct = $_POST['correct']; if (!is_numeric($count)) { //none, so the first $count = 0; $correct = 0; } if ($count == 0) { //yay the first question, so we get ten random questions from the db $numbers = Array(); $table = "quizfragen"; $where = "sprache = 'DE'"; $qcount = $db->getallRows($table, "id", $where); if (count($qcount) >= 10) { for ($i = 0; $i < count($qcount); $i++) { $numbers[] = $qcount[$i]['id']; } shuffle($numbers); $numbers = array_slice($numbers, 0, 10); } else { echo "Error! Not enough questions in the databank!"; die(); } } else { if ($_POST['answer'] == "") { //they did not choose one. decrease the count to redo the question $error = "

Bitte wählen Sie eine Antwort aus."; $count--; } //put the numbers into $numbers again $numbers = explode("|", $_POST['numberhidden']); } if ($count != 0 and !isset($error)) { //they answered the last question. check it. $showlastanswer = true; //get the text of their answer $table = "quizantworten"; $where = "id = ".$_POST['answer']; $theiranswer = $db->getRow($table, "antwort", $where); //get the question text and the id of the right answer $table = "quizfragen"; $where = "id = ".$_POST['qid']; $rightanswer = $db->getRow($table, "frage, antwort", $where); if ($rightanswer['antwort'] == $_POST['answer']) { //it was correct, increase the correct count $result = " Diese Antwort ist richtig."; $resultimg = "img/wasserquiz_richtig.jpg"; $correct++; } else { //it was incorrect, get the correct answer to display $table = "quizantworten"; $where = "id = ".$rightanswer['antwort']; $rightanswerq = $db->getRow($table, "antwort", $where); $result .= " Diese Antwort ist leider falsch.
Richtige Antwort: ".$rightanswerq['antwort'].""; $resultimg = "img/wasserquiz_falsch.jpg"; } } if ($count <= 9) { //it is not the last question //pass the numbers via hidden field $numberhidden = implode($numbers, "|"); //load the current question $table = "quizfragen"; $where = "id = ". $numbers[$count]; $question = $db->getRow($table, "frage, id", $where); $table = "quizantworten"; $where = "frage_id = ". $numbers[$count]; $answers = $db->getallRows($table, "antwort, id", $where); //create radio buttons with answers for ($i = 0; $i < count($answers); $i++) { $answerhtml .= ' '.$answers[$i]['antwort'].''; } } else { //flag to show the complete quiz results $showtotalresult = true; } //increase the count $count++; ?> FLOWCHEM®
FLOWCHEM<sup>®</sup>
Testen Sie hier Ihr Wissen über das wichtigste Element auf unserem Planeten.

zum Wasserquiz

Das große Wasserquiz

Herzlich Willkommen beim Wasserquiz

Testen Sie hier Ihr Wissen über das wichtigste Element auf unserem Planeten.
Viel Spaß!

Letzte Frage:
Ihre Antwort:

Sie haben von 10 Fragen richtig beantwortet.
Nochmal mitmachen.

Frage