Hallo zusammen,
Ich habe folgendes Formular mit ner iffset erstellt:
Alles anzeigen
Meine erste Frage - gibt es hier keine sinnvollere Lösung als wirklich 90 Zeilen zu bearbeiten und PHP konforme Statements daraus zu machen?
Meine zweite Frage - ich habe ja in jeder Zeile des Formulars nochmal ein Textfeld mit standard value 0 und der User muss aus der richtigen Antwort eine 1 machen. Ich hätte das gerne mit Checkboxen oder Kontrollfeldern ... nur krieg ich es einfach nicht hin ... habe soweit was mein Wissen angeht alles versucht.
Danke vorab,
Matthias
Ich habe folgendes Formular mit ner iffset erstellt:
Quellcode
- <? include("../dbconnect.php"); ?>
- <?
- $countgames = mysql_query("SELECT gameid, question from games_questions");
- $sumcount = mysql_num_rows($countgames);
- $newcount = $sumcount + 1;
- ?>
- <?php
- if(isset($_POST["Submit"])) {
- mysql_query("INSERT INTO games_questions (gameid,question,active) VALUES ($newcount,'$_POST[question]', '1')");
- mysql_query("INSERT INTO games_answers (gameid,answer,active)
- VALUES
- ($newcount,'$_POST[answer1]', '$_POST[active1]'),
- ($newcount,'$_POST[answer2]', '$_POST[active2]'),
- ($newcount,'$_POST[answer3]', '$_POST[active3]'),
- ($newcount,'$_POST[answer4]', '$_POST[active4]'),
- ($newcount,'$_POST[answer5]', '$_POST[active5]'),
- ($newcount,'$_POST[answer6]', '$_POST[active6]'),
- ($newcount,'$_POST[answer7]', '$_POST[active7]'),
- ($newcount,'$_POST[answer8]', '$_POST[active8]'),
- ($newcount,'$_POST[answer9]', '$_POST[active9]'),
- ($newcount,'$_POST[answer10]', '$_POST[active10]')
- ");
- echo "Quest wurde erfolgreich hinzugefügt";
- } else {
- echo "</p>";
- echo "<table width=\"748\" height=\"553\" border=\"0\" align=\"center\" background=\"../img/adm_bg.jpg\">";
- echo "<tr>";
- echo "<td><form name=\"addquest\" method=\"post\" action=\"".$PHP_SELF."\">";
- echo "<table width=\"550\" border=\"0\" align=\"center\">";
- echo "<tr>";
- echo "<td><span class=\"Stil1\">Neuen Quest hinzufügen </span></td>";
- echo "<td><div align=\"right\"><img src=\"../img/adm_new.jpg\" width=\"50\" height=\"53\"></div></td>";
- echo "</tr>";
- echo "</table>";
- echo "<table width=\"550\" border=\"0\" align=\"center\">";
- echo "<tr>";
- echo "<td width=\"133\">Frage:</td>";
- echo "<td width=\"318\"><input name=\"question\" type=\"text\" size=\"40\"></td>";
- echo "<td width=\"85\"> </td>";
- echo "</tr>";
- echo "<tr>";
- echo "<td> </td>";
- echo "<td> </td>";
- echo "<td> </td>";
- echo "</tr>";
- echo "<tr>";
- echo "<td>Antwort 1: </td>";
- echo "<input type=\"hidden\" name=\"answer1\" value=\"".$newcount."\">";
- echo "<td><input name=\"answer1\" type=\"text\" size=\"40\"></td>";
- echo "<td><input type=\"text\" size=\"1\" name=\"active1\" value=\"0\"></td>";
- echo "</tr>";
- echo "<tr>";
- echo "<td>Antwort 2: </td>";
- echo "<input type=\"hidden\" name=\"answer2\" value=\"".$newcount."\">";
- echo "<td><input name=\"answer2\" type=\"text\" size=\"40\"></td>";
- echo "<td><input type=\"text\" size=\"1\" name=\"active2\" value=\"0\"></td>";
- echo "</tr>";
- echo "<tr>";
- echo "<td>Antwort 3: </td>";
- echo "<input type=\"hidden\" name=\"answer3\" value=\"".$newcount."\">";
- echo "<td><input name=\"answer3\" type=\"text\" size=\"40\"></td>";
- echo "<td><input type=\"text\" size=\"1\" name=\"active3\" value=\"0\"></td>";
- echo "</tr>";
- echo "<tr>";
- echo "<td>Antwort 4: </td>";
- echo "<input type=\"hidden\" name=\"answer4\" value=\"".$newcount."\">";
- echo "<td><input name=\"answer4\" type=\"text\" size=\"40\"></td>";
- echo "<td><input type=\"text\" size=\"1\" name=\"active4\" value=\"0\"></td>";
- echo "</tr>";
- echo "<tr>";
- echo "<td>Antwort 5: </td>";
- echo "<input type=\"hidden\" name=\"answer5\" value=\"".$newcount."\">";
- echo "<td><input name=\"answer5\" type=\"text\" size=\"40\"></td>";
- echo "<td><input type=\"text\" size=\"1\" name=\"active5\" value=\"0\"></td>";
- echo "</tr>";
- echo "<tr>";
- echo "<td>Antwort 6: </td>";
- echo "<input type=\"hidden\" name=\"answer6\" value=\"".$newcount."\">";
- echo "<td><input name=\"answer6\" type=\"text\" size=\"40\"></td>";
- echo "<td><input type=\"text\" size=\"1\" name=\"active6\" value=\"0\"></td>";
- echo "</tr>";
- echo "<tr>";
- echo "<td>Antwort 7: </td>";
- echo "<input type=\"hidden\" name=\"answer7\" value=\"".$newcount."\">";
- echo "<td><input name=\"answer7\" type=\"text\" size=\"40\"></td>";
- echo "<td><input type=\"text\" size=\"1\" name=\"active7\" value=\"0\"></td>";
- echo "</tr>";
- echo "<tr>";
- echo "<td>Antwort 8: </td>";
- echo "<input type=\"hidden\" name=\"answer8\" value=\"".$newcount."\">";
- echo "<td><input name=\"answer8\" type=\"text\" size=\"40\"></td>";
- echo "<td><input type=\"text\" size=\"1\" name=\"active8\" value=\"0\"></td>";
- echo "</tr>";
- echo "<tr>";
- echo "<td>Antwort 9: </td>";
- echo "<input type=\"hidden\" name=\"answer9\" value=\"".$newcount."\">";
- echo "<td><input name=\"answer9\" type=\"text\" size=\"40\"></td>";
- echo "<td><input type=\"text\" size=\"1\" name=\"active9\" value=\"0\"></td>";
- echo "</tr>";
- echo "<tr>";
- echo "<td>Antwort 10: </td>";
- echo "<input type=\"hidden\" name=\"answer10\" value=\"".$newcount."\">";
- echo "<td><input name=\"answer10\" type=\"text\" size=\"40\"></td>";
- echo "<td><input type=\"text\" size=\"1\" name=\"active10\" value=\"0\"></td>";
- echo "<td><input type=\"submit\" name=\"Submit\" value=\"Senden\">";
- echo "</tr>";
- echo "</table>";
- echo "</form>";
- echo "</td>";
- echo "</tr>";
- echo "</table>";
- }
- ?>
Meine erste Frage - gibt es hier keine sinnvollere Lösung als wirklich 90 Zeilen zu bearbeiten und PHP konforme Statements daraus zu machen?
Meine zweite Frage - ich habe ja in jeder Zeile des Formulars nochmal ein Textfeld mit standard value 0 und der User muss aus der richtigen Antwort eine 1 machen. Ich hätte das gerne mit Checkboxen oder Kontrollfeldern ... nur krieg ich es einfach nicht hin ... habe soweit was mein Wissen angeht alles versucht.
Danke vorab,
Matthias
Das Leben ist binär - du bist eine 1, oder eine 0