-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuserdatabase.php
More file actions
125 lines (120 loc) · 5.81 KB
/
userdatabase.php
File metadata and controls
125 lines (120 loc) · 5.81 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
<?php
session_start();
include 'config.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php
include 'layout/header.php';
?>
</head>
<body class="index-page">
<?php
include 'layout/nav.php';
$type = $_GET["type"];
?>
<main class="main">
<section id="adminDashBoard" class="adminDashBoard section">
<div class="container history-container col-md-8 py-5 mb-5">
<div class="row pt-5">
<div class="col section-header">
<h2>User Database</h2>
</div>
</div>
<div class="row px-5 pb-5">
<?php if ($type == 'user'): ?>
<table class="table">
<tr>
<th width="10%">ID</th>
<th>User Email</th>
<th width="20%">Join Date</th>
<th width="15%">Role</th>
<th width="10%">Action</th>
</tr>
<?php
$sql = "SELECT * FROM users";
$result = mysqli_query($conn, $sql);
if ($result) {
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
if ($row['user_role'] != 'admin') {
echo "<tr id='table_content'><td>" . $row['user_id'] . "</td>";
echo "<td>" . $row['user_email'] . "</td><td>" . $row['user_joinDate'] . "</td><td>" . $row['user_role'] . "</td>";
echo "<td><a href='profile_adminView.php?id=" . $row['user_id'] . "'>View</a></td>";
echo "</tr>" . "\n\t\t";
}
}
} else {
echo '<tr><td colspan="5">0 results</td></tr>';
}
} else {
echo "Error: " . mysqli_error($conn);
}
?>
</table>
<?php elseif ($type == 'donor'): ?>
<table class="table">
<tr>
<th width="10%">ID</th>
<th>User Email</th>
<th width="15%">Name</th>
<th width="30%">Join Date</th>
<th width="10%">Action</th>
</tr>
<?php
$sql = "SELECT * FROM donor INNER JOIN users ON donor.user_id = users.user_id";
$result = mysqli_query($conn, $sql);
if ($result) {
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
echo "<tr id='table_content'><td>" . $row['user_id'] . "</td>";
echo "<td>" . $row['user_email'] . "</td><td>" . $row['donor_name'] . "</td><td>" . $row['user_joinDate'] . "</td>";
echo "<td><a href='profile_adminView.php?id=" . $row['user_id'] . "'>View</a></td>";
echo "</tr>" . "\n\t\t";
}
} else {
echo '<tr><td colspan="5">0 results</td></tr>';
}
} else {
echo "Error: " . mysqli_error($conn);
}
?>
</table>
<?php elseif ($type == 'charity'): ?>
<table class="table">
<tr>
<th width="10%">ID</th>
<th>Charity Name</th>
<th width="30%">Join Date</th>
<th width="10%">Action</th>
</tr>
<?php
$sql = "SELECT * FROM charity INNER JOIN users ON charity.user_id = users.user_id";
$result = mysqli_query($conn, $sql);
if ($result) {
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
echo "<tr id='table_content'><td>" . $row['user_id'] . "</td>";
echo "<td>" . $row['charity_name'] . "</td><td>" . $row['user_joinDate'] . "</td>";
echo "<td><a href='profile_adminView.php?id=" . $row['user_id'] . "'>View</a></td>";
echo "</tr>" . "\n\t\t";
}
} else {
echo '<tr><td colspan="4">0 results</td></tr>';
}
} else {
echo "Error: " . mysqli_error($conn);
}
?>
</table>
<?php endif; ?>
</div>
</div>
</section>
<?php
include 'layout/footer.php';
?>
</main>
</body>
</html>