-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathranking.php
More file actions
148 lines (140 loc) · 6.72 KB
/
ranking.php
File metadata and controls
148 lines (140 loc) · 6.72 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/ranking.css">
<title>Ranking</title>
<link rel="icon" type="image/x-icon" href="/img/favicon.ico">
<?php
include("verificaLogin.php");
?>
</head>
<body>
<?php
include('db_infos.php');
try {
$conn = new PDO("mysql:host=$sname;dbname=jogomemoria", $uname, $pwd);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "SELECT * FROM `ranking` LIMIT 10";
$result = $conn->query($sql);
$count = $conn->query("SELECT COUNT(*) FROM `ranking` LIMIT 10");
$count = $count->fetchColumn();
} catch(PDOException $e) {
echo "Connection failed: " . $e->getMessage();
}
if($count > 0){
$row = $result->fetch(PDO::FETCH_LAZY);
$fuser = $row["username"];
$fmodo = $row["modo"];
$fdim = $row["dimensao"];
$fjogadas = $row["jogadas"];
}
if($count > 1){
$row = $result->fetch(PDO::FETCH_LAZY);
$suser = $row["username"];
$smodo = $row["modo"];
$sdim = $row["dimensao"];
$sjogadas = $row["jogadas"];
}
?>
<div class="darkScreen">
<header class="header">
<a href="index.php" class="goBackButton"><img src="img/back.png" alt=""></a>
</header>
<div class="boardContainer">
<div class="board"><img src="img/Star.svg" alt="">
<h1 class="rankingText">RANKING</h1><img src="img/Star.svg" alt="">
</div>
</div>
<div class="rankContainer">
<div class="podiumContainer">
<div class="placeContainer">
<h1 class="podiumUsername"><?php if($count > 2){$row = $result->fetch(PDO::FETCH_LAZY); echo $row['username'];}?></h1>
<div class="podium" id="thirdPlace">
<h1 class="place">3°</h1>
<div class="data">
<div class="textContainer">
<p class="dataText">Tabuleiro</p>
<h3 class="dataTitle"><?php if($count > 2){echo $row["dimensao"];}?></h3>
</div>
<div class="textContainer">
<p class="dataText">Jogadas</p>
<h3 class="dataTitle"><?php if($count > 2){echo $row["jogadas"];}?></h3>
</div>
<p class="dataText"><?php if($row['modo']==1) echo 'Contra o Tempo'; else echo 'Classico';?></p>
</div>
</div>
</div>
<div class="placeContainer">
<h1 class="podiumUsername"><?php if($count > 0){echo $fuser;}?></h1>
<div class="podium" id="firstPlace">
<h1 class="place">1°</h1>
<div class="data">
<div class="textContainer">
<p class="dataText">Tabuleiro</p>
<h3 class="dataTitle"><?php if($count > 0){echo $fdim;}?></h3>
</div>
<div class="textContainer">
<p class="dataText">Jogadas</p>
<h3 class="dataTitle"><?php if($count > 0){echo $fjogadas;}?></h3>
</div>
<p class="dataText"><?php if($count > 0){if($fmodo==1) echo 'Contra o Tempo'; else echo 'Classico';}?></p>
</div>
</div>
</div>
<div class="placeContainer">
<h1 class="podiumUsername"><?php if($count > 1){echo $suser;}?></h1>
<div class="podium" id="secondPlace">
<h1 class="place">2°</h1>
<div class="data">
<div class="textContainer">
<p class="dataText">Tabuleiro</p>
<h3 class="dataTitle"><?php if($count > 1){echo $sdim;}?></h3>
</div>
<div class="textContainer">
<p class="dataText">Jogadas</p>
<h3 class="dataTitle"><?php if($count > 1){echo $sjogadas;}?></h3>
</div>
<p class="dataText"><?php if($count > 1){if($smodo==1) echo 'Contra o Tempo'; else echo 'Classico';}?></p>
</div>
</div>
</div>
</div>
<div class="othersContainer">
<!--Loop here-->
<?php
if($count > 3){
for($i=4; $i<11; $i++) {
if($count >= $i){
$row = $result->fetch(PDO::FETCH_LAZY);
if($row['modo']==1)
$modo = 'Contra o Tempo';
else
$modo = 'Classico';
echo '<div class="othersContentLight">
<p class="othersPlace">'.$i.'°</p>
<p class="othersText">'.$row['username'].'</p>
<div class="textContainer">
<p class="dataText">Tabuleiro</p>
<h3 class="dataTitle">'.$row["dimensao"].'</h3>
</div>
<div class="textContainer">
<p class="dataText">Jogadas</p>
<h3 class="dataTitle">'.$row["jogadas"].'</h3>
</div>
<p class="othersText">'.$modo.'</p>
</div>';
}
}
} else {
echo '<p style="padding:30px;text-align:center;color:grey;">Demais posições desocupadas<p>';
}
?>
<!--fim de um container-->
</div>
</div>
</div>
</body>
</html>