49 lines
No EOL
1.8 KiB
PHP
49 lines
No EOL
1.8 KiB
PHP
<?php
|
|
include $_SERVER["DOCUMENT_ROOT"] . "/php/pages.php";
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="pl-PL">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Ranking - quiz.czem.eu</title>
|
|
<meta name="description" content="quiz czem.eu">
|
|
<link rel="stylesheet" href="/styles/main.css">
|
|
<link rel="stylesheet" href="menu.css">
|
|
</head>
|
|
|
|
<body>
|
|
<h1>Ranking</h1>
|
|
<div class="wrap">
|
|
<main>
|
|
<?php
|
|
$conn = connectDB();
|
|
$stmt = $conn->prepare("SELECT correctAnswers, UID, testTime FROM tests WHERE rank = 1 ORDER BY correctAnswers DESC, testTime ASC");
|
|
$stmt->execute();
|
|
$stmt->store_result();
|
|
$stmt->bind_result($correctAnswers, $UID, $testTime);
|
|
echo "<table class='rank'><th>Miejsce</th><th>Nazwa użytkownika</th><th>Poprawne</th><th>Wynik</th><th>Czas zapisania testu</th>";
|
|
$i = 0;
|
|
while ($stmt->fetch()) {
|
|
$stmtUser = $conn->prepare("SELECT username FROM users WHERE UID = ?");
|
|
$stmtUser->bind_param("i", $UID);
|
|
$stmtUser->execute();
|
|
$stmtUser->bind_result($username);
|
|
if ($stmtUser->fetch()) {
|
|
$i++;
|
|
$pr = $correctAnswers/20*100;
|
|
echo "<tr><td>$i</td><td>$username</td><td>$correctAnswers/20</td><td>$pr%</td><td>$testTime</td></tr>";
|
|
}
|
|
$stmtUser->close();
|
|
}
|
|
$stmt->close();
|
|
$conn->close();
|
|
echo "</table>"
|
|
?>
|
|
<h3><a href="../">Powrót</a></h3>
|
|
</main>
|
|
</div>
|
|
</body>
|
|
|
|
</html>
|