-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathleaderboard.php
More file actions
117 lines (109 loc) · 5.36 KB
/
Copy pathleaderboard.php
File metadata and controls
117 lines (109 loc) · 5.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Leaderboard</title>
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0" />
<style>
.container::before {
height: var(--before-height);
}
</style>
</head>
<body>
<header class="header">
<h1 class="logo"><a href="#"><i>Constantia<span class="logo2">Colorcap</span></i></a></h1>
<nav class="main-nav">
<a href="index.php">Home</a>
<a href="leaderboard.php">Leaderboard</a>
<a href="tabela.php">Tabela</a>
<a href="obstaw.php">Obstaw</a>
<div class="konto">
<a class="konto2" tabindex="0" href="konto.php?user_id=<?php include 'data.php'; echo $user_id; ?>">Konto<span id="user-icon" class="material-symbols-outlined">account_circle</span></a>
<div class="user-info">
<?php
include "session.php";
include 'data.php';
include 'database_data.php';
echo "<span class='user-name'>".$username."</span><br><hr style='width: 107%; position: relative; left: -10px; top: -4px;'><br>";
echo "<span style='position: relative; top: -20px;'>".$imie." ".$nazwisko."</span>";
?>
<span class="logout" onclick="logout()">Wyloguj</span>
</div>
</div>
</nav>
</header>
<article>
<div class="container">
<h1 style="margin-top: 20px;">Top 10</h1>
<?php
include 'dane_mistrzostwa.php'; //Dane dotyczące meczów, danej rundy, administratora i daty obstawienia.
include 'punkty.php'; //Dane dotyczące aktualizowania punktów użytkowników
$suma = 0;
$sql = "SELECT DISTINCT `ID`, `Imie`, `Nazwisko`, `Runda_1` AS `Runda 1`, `Runda_2` AS `Runda 2`, `Runda_3` AS `Runda 3`, `Runda_4` AS `Runda 4`, `Runda_5` AS `Runda 5`, `Mistrz`, `Punkty` FROM wyniki
ORDER BY wyniki.Punkty DESC LIMIT 10"; // Pobranie 10 użytkowników mających najwięcej punktów
$sql_users = "SELECT DISTINCT ID FROM runda1";
$query_users = mysqli_query($conn, $sql_users);
while ($row_user = mysqli_fetch_assoc($query_users)) {
$user_id = $row_user['ID'];
$sql_bets = "SELECT * FROM runda1 WHERE ID = $user_id";
$query_bets = mysqli_query($conn, $sql_bets);
$wytypowany_mistrz = "SELECT * FROM runda1 WHERE ID = $user_id";
$wytypowany_result = mysqli_query($conn, $wytypowany_mistrz);
$sql2 = "SELECT DISTINCT ID, Wytypowany_Mistrz FROM runda1 WHERE ID = $user_id";
$result2 = mysqli_query($conn, $sql2);
while ($row2 = mysqli_fetch_array($result2)) {
$mistrz = $row2['Wytypowany_Mistrz'];
$mistrz_sql = "UPDATE wyniki SET Mistrz = '$mistrz' WHERE ID = $user_id"; //Wyświetlenie wytypowanego mistrza przez użytkownika
mysqli_query( $conn, $mistrz_sql);
}
}
$result = mysqli_query($conn, $sql);
$columns = $result->fetch_fields();
echo '<table id="tabela" border="2" cellspacing="0" >';
foreach ($columns as $column){
if ($column->name == 'ID'){
echo '<th style="background-color: #111;">Miejsce</th>';
}else{
echo '<th style="background-color: #111;">'.$column->name.'</th>'; // Wyświetlanie nagłówków tabeli, Np. Runda1 etc.
}
}
echo '<tr></tr>';
$i=1;
mysqli_data_seek($result, 0);
while ($row = mysqli_fetch_assoc($result)){
echo '<tr>'; //Nowy wiersz
foreach ($row as $key => $value){
if ($key === "ID"){
echo '<td style="color: yellow; font-size: 20px;">'.$i.'</td>';
}else if ($key === "Punkty"){
echo '<td style="color: yellow; font-size: 20px;">'.$value.'</td>'; // Wyświetlanie danych z danej kolumny
}else{
echo '<td>'.$value.'</td>';
}
}
echo '</tr>'; //Koniec wiersza
$i++;
}
echo '</table>'; // Zamknięcie tabeli
?>
</div>
</article>
<script>
function logout() {
window.location.href = "logout.php";
}
window.addEventListener('load', function() {
var container = document.querySelector('.container');
if (container) {
var height = container.offsetHeight;
document.querySelector('.container').style.setProperty('--before-height', height + 75 + 'px');
} else {
console.error('Nie można znaleźć tego id');
}
});
</script>
</body>
</html>