Update
This commit is contained in:
@@ -69,5 +69,20 @@ class Database
|
||||
return $resultArray;
|
||||
}
|
||||
|
||||
public function getQuestion($id)
|
||||
{
|
||||
$result = $this->connection->query("SELECT * FROM questions WHERE id = $id LIMIT 1");
|
||||
|
||||
$resultArray = [];
|
||||
|
||||
while ($line = $result->fetch_assoc()) {
|
||||
array_push($resultArray, $line);
|
||||
}
|
||||
|
||||
$result->free();
|
||||
|
||||
return $resultArray[0];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
49
cgi-bin/uebung09/questions-edit.php
Normal file
49
cgi-bin/uebung09/questions-edit.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
$id = $_GET['id'];
|
||||
$db = new Database();
|
||||
|
||||
$question = $db->getQuestion($id);
|
||||
$sol = $question['solution'];
|
||||
|
||||
echo <<<END
|
||||
<h1>Frage bearbeiten</h1><form action="questions-update.php" method="post">
|
||||
<input type="hidden" name="id" value="$id">
|
||||
|
||||
<label for="question">Frage:</label> <br>
|
||||
<textarea name="question" id="question">$question['question']</textarea> <br><br>
|
||||
|
||||
<label for="answer0">Antwort 0:</label>
|
||||
<div class="form-box">
|
||||
END;
|
||||
|
||||
echo('<input class="form-solution" type="radio" name="solution" value="0" required' . (($sol == 0) ? "checked" : "") . ">");
|
||||
|
||||
echo <<<END
|
||||
<input class="form-answer" type="text" name="answer0" id="answer0" required value=$question['answer0']>
|
||||
</div>
|
||||
|
||||
<label for="answer1">Antwort 1:</label>
|
||||
<div class="form-box">
|
||||
END;
|
||||
echo('<input class="form-solution" type="radio" name="solution" value="1" required' . (($sol == 1) ? "checked" : "") . '>');
|
||||
|
||||
echo <<<END
|
||||
<input class="form-answer"type="text" name="answer1" id="answer1" value=$question['answer1']>
|
||||
</div>
|
||||
|
||||
<label for="answer2">Antwort 2:</label>
|
||||
<div class="form-box">
|
||||
END;
|
||||
echo('<input class="form-solution" type="radio" name="solution" value="2" required' . (($sol == 2) ? "checked" : "") . ">");
|
||||
|
||||
echo <<<END
|
||||
<input class="form-answer" type="text" name="answer2" id="answer2" value=$question['answer2']>
|
||||
</div>
|
||||
|
||||
<button>Frage aktualisieren</button>
|
||||
|
||||
</form>
|
||||
END;
|
||||
|
||||
?>
|
Reference in New Issue
Block a user