-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin_userSelect.php
101 lines (70 loc) · 2.96 KB
/
admin_userSelect.php
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
<?php
include 'bbdd_db_conn.php';
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
session_start();
$adminCast = "admin";
$editorCast = "editor";
$authorCast = "author";
$uname = $_SESSION['username'];
// $sql = "SELECT * FROM user_data ORDER BY id DESC";
$URL = "./admin_index.php";
if(!isset($_SESSION['username'])) {
?> <script>
// alert("권한이 없습니다.");
location.replace("<?php echo $URL?>");
</script>
<?php }
//cast: admin인 경우
else if($_SESSION['cast']==$adminCast) {
$sql = "SELECT * FROM user_data ORDER BY id DESC";
} else if ($_SESSION['cast']==$editorCast) {
$sql = "SELECT * FROM user_data WHERE `cast` != '$adminCast' ORDER BY id DESC";
} else if ($_SESSION['cast']!==$adminCast && $_SESSION['cast']!==$editorCast) {
$sql = "SELECT * FROM user_data WHERE username = '$uname' ORDER BY id DESC";
}
$result = $conn->query($sql) or die($conn->error);
echo "<tr>
<th onclick='sortTable(0)'>번호</th>
<th onclick='sortTable(1)'>아이디</th>
<th onclick='sortTable(2)'>이메일</th>
<th onclick='sortTable(3)'>필명</th>
<th onclick='sortTable(4)'>이름</th>
<th onclick='sortTable(5)'>등급</th>
<th >관리</th>
</tr>";
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
// echo "<li id='{$row["id"]}' onclick = 'showClickedObject(this.id)'>"/*."<a href='VisitContentClick()'>"*/.
// "<h3>{$row['title']}</h3>".
// "<img src='{$row['img0_dir']}' width='210px' heigit='70px'>".
// " ".
// $row["username"].
// " ".
// $row["created"].
// "</a>".
// "</li>";
// <td class='{$row["id"]}'><img src='{$row['img_dir']}' width='90px' heigit='60px'></td>
echo
"<tr id='{$row["id"]}' >
<td class='{$row["id"]}'>{$row['id']}</td>
<td class='{$row["id"]}'>{$row['username']}</td>
<td class='{$row["id"]}'>{$row['email']}</td>
<td class='{$row["id"]}'>{$row['author']}</td>
<td class='{$row["id"]}'>{$row['realname']}</td>
<td class='{$row["id"]}'>{$row['cast']}</td>
<td class='{$row["id"]}'><button class='view_btn1' name='{$row["id"]}' onclick='userModi(this.name)'>수정</button>";
echo " | ";
echo "<button class='view_btn1' name='{$row["id"]}' onclick='userDel(this.name)'>삭제</button></td>
</tr>";
}
} else {
echo "0 results";
}
$conn->close();
?>
<!-- <script src="imgList.js"></script> -->
<!-- <script src="sortTable.js"></script> -->
<!-- <td id='{$row["id"]}' class='{$row["id"]}' onclick = 'imgList(this.id)'>{$row['title']}</td> -->