-
Notifications
You must be signed in to change notification settings - Fork 0
/
resources.php
265 lines (231 loc) · 8.93 KB
/
resources.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
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
<?php
require "config/config.php";
// DB Connection
$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
if ( $mysqli->connect_errno ) {
echo $mysqli->connect_error;
exit();
}
$mysqli->set_charset('utf8');
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>COVID-19 Report</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="css/style.css">
<script src="https://kit.fontawesome.com/2b38a0d5c8.js" crossorigin="anonymous"></script>
<link href="https://fonts.googleapis.com/css2?family=Karla:wght@400;700&display=swap" rel="stylesheet">
</head>
<body>
<div class="container" id="header">
<div class="row">
<div class="col-12">
<nav class="navbar navbar-dark justify-content-center">
<a class="navbar-brand" href="index.html">
<h1><i class="fas fa-shield-virus fa-lg"></i> COVID-19 Report</h1>
</a>
</nav>
</div>
</div>
</div>
<div class="container" id="nav">
<div class="row">
<div class="col-12">
<ul class="nav justify-content-center">
<li class="nav-item">
<a class="nav-link" href="index.html">Home</a>
</li>
<li class="nav-item">
<a class="nav-link active" href="resources.php">Resources</a>
</li>
<li class="nav-item">
<a class="nav-link" href="bookmarks.html">Bookmarks</a>
</li>
</ul>
</div>
</div>
</div>
<div class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" style="color: black">Confirm</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p style="color: black">Are you sure you want to delete this?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary confirm-delete">Delete</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div class="container" id="resources">
<div class="row">
<div class="col-12 text-right">
<a class="btn btn-secondary" data-toggle="collapse" href="#viewOrganizations" role="button" aria-expanded="false" aria-controls="collapseExample">
View Organizations
</a>
<div class="btn-group" role="group">
<button id="btnGroupDrop1" type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Add
</button>
<div class="dropdown-menu" aria-labelledby="btnGroupDrop1">
<a class="dropdown-item" href="add_resource.php">Resource</a>
<a class="dropdown-item" href="add_organization.php">Organization</a>
</div>
</div>
</div>
</div>
<div class="row my-3">
<div class="col-12">
<div class="collapse" id="viewOrganizations">
<div class="card card-body" id="organizationsList">
<?php
$sql = "SELECT * FROM organizations;";
$results = $mysqli->query($sql);
if ( $results == false ) {
echo $mysqli->error;
exit();
}
?>
<?php if ($results->num_rows == 0) : ?>
<h5>No available organizations.</h5>
<?php endif; ?>
<ul>
<?php while ( $row = $results->fetch_assoc() ) : ?>
<li><?php echo $row['organization']; ?> (<a href="<?php echo $row['link']; ?>" target="_blank">Link</a>)</li>
<?php endwhile; ?>
</ul>
</div>
</div>
</div>
</div>
<div class="row my-3">
<div class="col-12">
<h3>Health</h3>
</div>
<div class="col-12 overflow-auto rounded" id="health">
<div class="row">
<?php
$sql = "SELECT resources.id, resources.description, resources.link, organizations.organization
FROM resources
JOIN organizations
ON resources.organization_id = organizations.id
WHERE category_id = 1;";
$results = $mysqli->query($sql);
if ( $results == false ) {
echo $mysqli->error;
exit();
}
?>
<?php while ( $row = $results->fetch_assoc() ) : ?>
<div class="col-12 col-md-6 col-lg-4">
<div class="card mb-3">
<div class="card-body text-center">
<h5><?php echo $row['organization']; ?></h5>
<p class="card-text overflow-auto"><?php echo $row['description']; ?></p>
<div class="text-center">
<a href="<?php echo $row['link']; ?>" target="_blank">Link</a> <a class="ml-5 text-warning" href="edit_resource.php?resource_id=<?php echo $row['id']; ?>">Edit</a> <a id="<?php echo $row['id']; ?>" class="ml-5 text-danger delete">Delete</a>
</div>
</div>
</div>
</div>
<?php endwhile; ?>
</div>
</div>
</div>
<div class="row my-3">
<div class="col-12">
<h3>Financial</h3>
</div>
<div class="col-12 overflow-auto rounded" id="financial">
<div class="row">
<?php
$sql = "SELECT resources.id, resources.description, resources.link, organizations.organization
FROM resources
JOIN organizations
ON resources.organization_id = organizations.id
WHERE category_id = 2;";
$results = $mysqli->query($sql);
if ( $results == false ) {
echo $mysqli->error;
exit();
}
?>
<?php while ( $row = $results->fetch_assoc() ) : ?>
<div class="col-12 col-md-6 col-lg-4">
<div class="card mb-3">
<div class="card-body text-center">
<h5><?php echo $row['organization']; ?></h5>
<p class="card-text overflow-auto"><?php echo $row['description']; ?></p>
<div class="text-center">
<a href="<?php echo $row['link']; ?>" target="_blank">Link</a> <a class="ml-5 text-warning" href="edit_resource.php?resource_id=<?php echo $row['id']; ?>">Edit</a> <a id="<?php echo $row['id']; ?>" class="ml-5 text-danger delete">Delete</a>
</div>
</div>
</div>
</div>
<?php endwhile; ?>
</div>
</div>
</div>
<div class="row my-3">
<div class="col-12">
<h3>Community</h3>
</div>
<div class="col-12 overflow-auto rounded" id="community">
<div class="row">
<?php
$sql = "SELECT resources.id, resources.description, resources.link, organizations.organization
FROM resources
JOIN organizations
ON resources.organization_id = organizations.id
WHERE category_id = 3;";
$results = $mysqli->query($sql);
if ( $results == false ) {
echo $mysqli->error;
exit();
}
?>
<?php while ( $row = $results->fetch_assoc() ) : ?>
<div class="col-12 col-md-6 col-lg-4">
<div class="card mb-3">
<div class="card-body text-center">
<h5><?php echo $row['organization']; ?></h5>
<p class="card-text overflow-auto"><?php echo $row['description']; ?></p>
<div class="text-center">
<a href="<?php echo $row['link']; ?>" target="_blank">Link</a> <a class="ml-5 text-warning" href="edit_resource.php?resource_id=<?php echo $row['id']; ?>">Edit</a> <a id="<?php echo $row['id']; ?>" class="ml-5 text-danger delete">Delete</a>
</div>
</div>
</div>
</div>
<?php endwhile; ?>
</div>
</div>
</div>
</div>
<div class="container" id="footer">
<div class="row">
<div class="col-12 mt-2 mb-5">
<p class="card-text">Crafted with <i class="fas fa-heart" id="heart"></i> by <a href="https://www.tranngo.com/">Tran Ngo</a></p>
</div>
</div>
</div>
<?php
// Close DB Connection.
$mysqli->close();
?>
<script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.js" integrity="sha256-R4pqcOYV8lt7snxMQO/HSbVCFRPMdrhAFMH+vr9giYI=" crossorigin="anonymous"></script>
<script src="js/resources.js"></script>
</body>
</html>