Repository navigation
Expand file tree
/
Copy pathmypageRank.php
More file actions
283 lines (243 loc) · 6.92 KB
/
Copy pathmypageRank.php
File metadata and controls
283 lines (243 loc) · 6.92 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
<?php
session_start();
if(!isset($_SESSION['login_session'])){
header("Location:./index.html");
}
if(!isset($_SESSION['login_session'])){
header("Location:./index.html");
}
$host = 'localhost';
$user = 'root';
$pw = 'chanki';
$dbname = 'healthcare';
$dbconnection = new mysqli($host, $user, $pw, $dbname);
$dbconnection->set_charset("utf8");
$time = date("Y-m-d");
$time_month = date("Y-m");
$sql_walk = " SELECT sum(walk) FROM healthinfo WHERE time like '{$time}' and memberId like '{$_SESSION['login_session']['memberId']}' ";
$sql_rank = "SELECT ANY_VALUE(name), sum(walk),ANY_VALUE(memberId)
FROM healthinfo WHERE name in
(
SELECT name
FROM userinfo
WHERE teamname
like '{$_SESSION['login_session']['teamName']}' AND
auth like 'true'
)
AND time like '{$time}'
GROUP BY memberId
ORDER BY sum(walk) DESC";
$res_rank = $dbconnection ->query($sql_rank);
$sql_rank_month =" SELECT ANY_VALUE(name), sum(walk),ANY_VALUE(memberId)
FROM healthinfo WHERE name in
(
SELECT name
FROM userinfo
WHERE teamname
like '{$_SESSION['login_session']['teamName']}' AND
auth like 'true'
)
AND time like '{$time_month}%'
GROUP BY memberId
ORDER BY sum(walk) DESC";
$res_rank_month = $dbconnection ->query($sql_rank_month);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>당신의 건강정보</title>
</head>
<style>
body {
margin:0;
padding:0;
margin-top:0px;
padding-top : 0px ;
/* background-color: #454545; */
}
.left_menu {
height: 15%;
width: 100%;
display: block;
z-index: 1;
background-color: #454545;
overflow: hidden;
margin: 0px;
padding: 0px;
font-size: 1.2rem;
clear:both;
}
.input_button{
display: inline;
margin-left: 10px;
}
.input_button input{
display: inline-block;
background-color: #282C34;
padding: 5px;
border-radius : .4rem;
font-size : .8rem;
color : white;
}
}
.card input{
border-style: none;
border-bottom : 3px dotted #282C34;
padding-left: 5px;
font-size : .5rem;
outline: none;
}
form{
display: inline;
}
.left_menu a {
padding: 10px 8px 15px 16px;
text-decoration: none;
font-size: 1.2rem;
color: white;
display: inline-block;
}
.left_menu a:hover {
color: #f1f1f1;
}
.main_page{
text-align: center;
width: 100%;
display: inline-block;
border-radius: .4rem;
background-color: #E0E2E3;
}
}
.main_page .status_bar{
text-align: center;
background-color: #E0E2E3;
padding: 15px 10px;
border-radius: .4rem;
display: block;
}
.today_rank, .monthly-rank{
background-color: #E0E2E3;
margin-top: 20px;
text-align: center;
}
.dashboard{
width : 100%;
background-color : ivory;
}
.card {
margin: 15px 10px 5px 10px;
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
transition: 0.3s;
width: 200px;
height: 200px;
display: inline-block;
}
.card:hover {
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2);
}
.container {
padding: 2px 16px;
}
.table, .table1, .table2{
text-align: center;
margin: 10px;
}
table {
border-collapse: separate;
border-spacing: 0;
text-align: left;
line-height: 1.5;
border-top: 1px solid #ccc;
border-left: 1px solid #ccc;
margin : auto;
}
table th {
/* display: inline-flex; */
padding: 10px;
font-weight: bold;
text-align: center;
vertical-align: top;
border-right: 1px solid #ccc;
border-bottom: 1px solid #ccc;
border-top: 1px solid #fff;
border-left: 1px solid #fff;
background: #eee;
}
table td {
/* display: inline-flex; */
padding: 10px;
text-align: center;
vertical-align: top;
border-right: 1px solid #ccc;
border-bottom: 1px solid #ccc;
color: white;
background-color: #454545;
width: 70px;
}
input{
border-style: none;
border-bottom : 3px dotted #282C34;
padding-left: 5px;
font-size : 1rem;
outline: none;
}
</style>
<body>
<div class="left_menu">
<a href="./mypage_dashboard.php">Dashboard</a>
<a href="./mypage.php">건강정보 입력</a>
<a href="./mypageRank.php">팀 내의 경쟁순위</a>
<a href="./shorttable.php">게시판</a>
<a href="./logout.php" style="float : right">logout</a>
<a href="./myinfo.php" style="float : right">개인 설정</a>
<a href="./gamdok.php" style="float : right">감독 메뉴</a>
</div>
<div class="main_page">
<div class="status_bar">
<h4><?=$_SESSION['login_session']['teamName']; ?>(팀)에 속해 계시는 <?=$_SESSION['login_session']['name']; ?>님 반갑습니다.
<?php if ($_SESSION['login_session']['director'] == "true") {print "직책 : 감독";} else {print "일반 사용자입니다";}?></h4>
</div>
</div>
<div class="today_rank">
<h3>금일 팀 내의 걸음 순위 입니다.<br>
입력하지 않은 사람은 목록에서 제외됩니다.<br>
팀 이름 : <?=$_SESSION['login_session']['teamName'];?>
</h3>
<h3>
<div class="table">
<?php
while($row = mysqli_fetch_row($res_rank)) {
echo "<table>";
echo "<tr>";
echo "<th>이름</th> <td> {$row[0]} </td>";
echo "<th>걸은 거리</th> <td> {$row[1]} km</td>";
echo "<th>이름을 구별하기 위한 고유 번호</th> <td> {$row[2]} </td>";
echo "</tr>";
echo "</table>";
}
?>
</div>
</h3>
</div>
<div class="monthly-rank">
<h3>월간 순위입니다. 아무도 없을 경우 표시되지 않습니다.</h3>
<div class="table">
<h3>
<?php
while($row = mysqli_fetch_row($res_rank_month)) {
echo "<table>";
echo "<tr>";
echo "<th>이름: </th> <td> {$row[0]} </td>";
echo "<th>걸은 거리 (km): </th> <td> {$row[1]} </td>";
echo "<th>월 평균 걸은 거리 (km): </th> <td> " ; echo number_format((float)$row[1]/date("t"), 2, '.', ''); echo "km</td>";
echo "<th>이름을 구별하기 위한 고유 번호</th> <td> {$row[2]}</td>";
echo "</tr>";
echo "</table>";
}
?>
</h3>
</div>
</div>
</body>
</html>