-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtabled.php
217 lines (200 loc) · 7.38 KB
/
tabled.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
<?php
require_once 'connect.php';
//Deletes empty records
$sql='DELETE from reports WHERE Location="" OR Area=""';
$retval = mysqli_query( $db,$sql);
if(! $retval )
{
die('Could not delete data: ' . mysql_error());
}
//delete info
if(isset($_POST['delete']))
{
$loc=mysqli_real_escape_string($db , $_GET["delete"] );
$sql="DELETE from reports WHERE Location LIKE '$loc%'";
$retval = mysqli_query( $db,$sql);
if(! $retval )
{
die('Could not delete data: ' . mysql_error());
}
}
//work on code above
/*Display all data in table
*All data filtered by Date
*Latest data will be shown first
*/
$query="SELECT * FROM `reports`ORDER by Report_Date DESC ";
$result=mysqli_query($db,$query);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<!--Auto Refresh-->
<meta http-equiv="refresh" content="10" >
<title>iGen</title>
<!-- Bootstrap core CSS -->
<link href="css/min_ss.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="css/business-frontpage.css" rel="stylesheet">
<script type="text/javascript">
function Alert() {
var aa = confirm("Do you want to continue");
if (aa == true) {
alert("Alert Sent!! // send alert by location: feature coming soon");
return true;
} else {
alert("Cancelled");
return false;
}
}
function makeTableScroll() {
// Constant retrieved from server-side via JSP
var maxRows = 8;
var table = document.getElementById('myTable');
var wrapper = table.parentNode;
var rowsInTable = table.rows.length;
var height = 0;
if (rowsInTable > maxRows) {
for (var i = 0; i < maxRows; i++) {
height += table.rows[i].clientHeight;
}
wrapper.style.height = height + "px";
}
}
</script>
<style>
#myInput {
background-position: 10px 10px;
background-repeat: no-repeat;
width: 22%;
font-size: 15px;
padding: 1px 20px 12px 40px;
border: 1px solid #ddd;
margin-bottom: 40px;
margin-left: 250px;
}
table {
border: black;
border-collapse: collapse;
margin: 2px;
text-align: center;
font-size: 15px;
}
th {
column-width: 3.5cm;
height: 1.28cm;
background-color: #343a40;
color: white;
font-weight: 700;
position: static;
}
h1 {}
.scrollingTable {
width: 100%;
overflow-y: auto;
}
.navbar-brand {
font-size: 15px;
font-weight: lighter;
font-family: sans-serif;
color: grey;
}
body{
background-color:whitesmoke;
}
</style>
</head>
<body onload="makeTableScroll();">
<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
<div class="container">
<a class="navbar-brand" href="adminhome.php">Home</a>
<a class="navbar-brand" href="about.html">Latest Feeds</a>
<a class="navbar-brand" href="indexadmin.php">Logout</a>
</div>
</nav>
<!-- Header with Background Image -->
<header class="business-header" style="min-height: 140px;background-image:url(resources/images/report.jpg)">
<div class="container">
<div class="row">
<div class="col-lg-12">
<h1 class="display-3 text-center mt-4" style="font-weight: bold;font-size: 40px; color:sandybrown">Reports Generated</h1>
<hr style="width: 15cm">
</div>
</div>
</div>
</header>
<div class="container">
<p>Reports are generated according to user incidence description input and are adequately presented in the table below: </p>
<hr>
</div>
<!--Search feature-->
<input type="text" id="myInput" onkeyup="myFunction()" placeholder="Search by location.." align="center">
<br>
<div class="container">
<div class="scrollingTable">
<table align="center" border="0.5px" style="width:600pxr" id="myTable">
<tr>
<th style="border-top-left-radius: 10px">Location</th>
<th>Area / Road</th>
<th>Vehicle Type and Plate</th>
<th>iDescription</th>
<th>DatePosted</th>
<th style=" border-top-right-radius: 10px">Options</th>
</tr>
<?php
while ($rows=mysqli_fetch_assoc($result))
{
?>
<tr>
<td>
<?php echo $rows['Location']; ?>
</td>
<td>
<?php echo $rows['Area']; ?>
</td>
<td>
<?php echo $rows['Vehicle_color']; ?>
<?php echo $rows['Vehicle_Type']; ?>
<br>
<?php echo $rows['Plate_Number']; ?>
</td>
<td>
<?php echo $rows['Description']; ?>
</td>
<td>
<?php echo $rows['Report_Date']; ?>
</td>
<td>
<input id="alert" type="submit" name="alert" value="Send Alert" class="btn btn-primary" onclick="Alert()" style="font-weight:bold">
</td>
</tr>
<?php
}
?>
</table>
</div>
</div>
<!--Search table using location-->
<script>
function myFunction() {
var input, filter, table, tr, td, i;
input = document.getElementById("myInput");
filter = input.value.toUpperCase();
table = document.getElementById("myTable");
tr = table.getElementsByTagName("tr");
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[0];
if (td) {
if (td.innerHTML.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
}
</script>
</body>
</html>