-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd-place.php
155 lines (139 loc) · 4.76 KB
/
add-place.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
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . '/CovidTracker/assets/php/config.php';
?>
<!DOCTYPE HTML>
<html>
<head>
<title>cards</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<link rel="stylesheet" href="assets/css/main.css" />
<noscript><link rel="stylesheet" href="assets/css/noscript.css" /></noscript>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script>
$(document).ready(function(){
$('.search-box input[type="text"]').on("keyup input", function(){
/* Get input value on change */
var inputVal = $(this).val();
var resultDropdown = $(this).siblings(".result");
if(inputVal.length){
$.get("assets/php/backend-search.php", {term: inputVal}).done(function(data){
// Display the returned data in browser
resultDropdown.html(data);
});
} else{
resultDropdown.empty();
}
});
// Set search input value on click of result item
$(document).on("click", ".result p", function(){
$(this).parents(".search-box").find('input[type="text"]').val($(this).text());
$(this).parent(".result").empty();
});
});
$(document).ready(function(){
$("#searchit").on("keyup", function() {
var value = $(this).val().toLowerCase();
$("#countries tr").filter(function() {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
});
});
});
$("#searchit").keyup(function () {
var value = this.value.toLowerCase().trim();
$("#countries tr").each(function (index) {
if (!index) return;
$(this).find("td").each(function () {
var id = $(this).text().toLowerCase().trim();
var not_found = (id.indexOf(value) == -1);
$(this).closest('tr').toggle(!not_found);
return not_found;
});
});
});
</script>
</head>
<body class="is-preload">
<!-- Wrapper -->
<div id="wrapper">
<!-- Header -->
<header id="header">
<div class="inner">
<!-- Logo -->
<a href="admin-panel.php" class="logo">
<span class="symbol"><img src="images/logo.png" alt="" /></span><span class="title">Covid Tracker</span>
</a>
</div>
</header>
<!-- Main -->
<div id="main">
<div class="inner">
<h1>Countries</h1>
<div class="row">
<div>
<ul class="actions">
<li><a href="assets/php/create.php" class="button large"><i class="fa fa-plus"></i> Add a Country</a></li>
</ul>
</div>
<form method="POST" action="">
<div class="search-box">
<input id="searchit" type="text" autocomplete="off" name="search" placeholder="Search country..." />
<div class="result"></div>
</div>
</form>
</div>
<!-- Table -->
<section>
<div class="table-wrapper">
<?php
$query = "SELECT * from places limit 100;";
$result = $db->query($query);
?>
<table>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Cases</th>
<th>Deaths</th>
<th>Recovered</th>
<th>Actions</th>
</tr>
</thead>
<tbody id="countries">
<?php
while($row = $result->fetch_array()){
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['cases'] . "</td>";
echo "<td>" . $row['deaths'] . "</td>";
echo "<td>" . $row['recovered'] . "</td>";
echo "<td>";
echo '<a href="assets/php/read.php?id='. $row['id'] .'" class="icon style1" title="View Record" data-toggle="tooltip"><span class="fa fa-eye"></span></a> ';
echo '<a href="assets/php/update.php?id='. $row['id'] .'" class="icon style1" title="Update Record" data-toggle="tooltip"><span class="fa fa-edit"></span></a> ';
echo '<a href="assets/php/delete.php?id='. $row['id'] .'" class="icon style1" title="Delete Record" data-toggle="tooltip"><span class="fa fa-trash"></span></a>';
echo "</td>";
echo "</tr>";
}
?>
</tbody>
</table>
<?php
$db->close();
?>
</div>
</section>
</div>
</div>
<!-- Footer -->
<footer id="footer">
<div class="inner">
<ul class="copyright">
<li>© E Lara. All rights reserved</li>
</ul>
</div>
</footer>
</div>
</body>
</html>