quiz-klapek/score/questions/index.php
2025-06-15 22:04:08 +02:00

51 lines
No EOL
2 KiB
PHP

<?php
include $_SERVER["DOCUMENT_ROOT"] . "/php/pages.php";
redirectLogged();
?>
<!DOCTYPE html>
<html lang="pl-PL">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Zapisane pytania - quiz.czem.eu</title>
<link rel="stylesheet" href="/styles/main.css">
</head>
<body>
<h1>Zapisane pytania</h1>
<div class="wrap">
<main>
<?php
$conn = connectDB();
$stmt = $conn->prepare("SELECT QID, answerChar, correct, questionTime FROM questionanswers WHERE UID = ?");
$stmt->bind_param("i", $_SESSION["UID"]);
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($QID, $answeredChar, $correct, $questionsTime);
echo "<table><tr><th>Pytanie</th><th>Odpowiedzi</th><th>Twoja odpowiedź</th><th>Prawidłowa?</th><th>Prawidłowa odpowiedź</th><th>Czas zapisania odpowiedzi na pytanie</th></tr>";
while ($stmt->fetch()) {
$stmtQuestion = $conn->prepare("SELECT content, answerA, answerB, answerC, answerD, answerChar FROM questions WHERE QID = ?");
$stmtQuestion->bind_param("i", $QID);
$stmtQuestion->execute();
$stmtQuestion->bind_result($content, $answerA, $answerB, $answerC, $answerD, $answerChar);
if ($stmtQuestion->fetch()) {
$right = $correct ? "tak" : "nie";
echo "<tr><td rowspan='4'>$content</td><td>A: $answerA</td><td rowspan='4'>$answeredChar</td><td rowspan='4'>$right</td><td rowspan='4'>$answerChar</td><td rowspan='4'>$questionsTime</td></tr>
<tr><td>B: $answerB</td></tr>
<tr><td>C: $answerC</td></tr>
<tr><td>D: $answerD</td></tr>";
}
$stmtQuestion->close();
}
$stmt->close();
$conn->close();
echo "</table>";
?>
<h3><a href="../">Powrót</a></h3>
</main>
</div>
</body>
</html>