-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
218 lines (189 loc) · 7.38 KB
/
search.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
<?php
// Start the session
session_start();
if(!$_SESSION['loggedIn']){
header('Location: /crimelogs/login.php');
}
include('conn.php');
if (isset($_GET['entry']))
$pageno = (int)($_GET['entry']);
else
$pageno = 1;
$RECORDS_PER_PAGE = 7;
if (isset($_GET["term"])&&isset($_GET["query"])){
$term = $_GET["term"];$query = $_GET["query"];
$totalrecordsSQL = "SELECT * FROM criminal WHERE $term LIKE '%$query%'";
$start_from=($pageno-1)*$RECORDS_PER_PAGE ;
$criminaldata_query="SELECT * FROM criminal WHERE $term LIKE '%$query%' LIMIT $start_from, $RECORDS_PER_PAGE";
$prevURL = '?entry='.($pageno-1)."&term=$term&query=$query";
$nextURL = '?entry='.($pageno+1)."&term=$term&query=$query";
}
else{
$totalrecordsSQL = "SELECT * FROM criminal";
$start_from=($pageno-1)*$RECORDS_PER_PAGE ;
$criminaldata_query="SELECT * FROM criminal LIMIT $start_from, $RECORDS_PER_PAGE";
$a=$pageno-1;$b=$pageno+1;
$prevURL = "?entry=$a";
$nextURL = "?entry=$b";
}
$criminaldata=$conn->query($criminaldata_query);
$totalrecords=$conn->query($totalrecordsSQL);
$totalpage = ceil($totalrecords->num_rows/$RECORDS_PER_PAGE);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>Search Records - CrimeLogs</title>
<!-- Font Awesome -->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css">
<!-- Material Design Bootstrap -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.19.1/css/mdb.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<link href="style.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
$('.btn-search').click(function(){
var term = $('#inputGroupSelect04').val();
var query = $('#searchinput').val();
var searchURL = "?entry=1&term="+term+"&query="+query;
window.location = searchURL;
});
<?php if (isset($_GET["term"])&&isset($_GET["query"])): ?>
$('#inputGroupSelect04').val('<?php echo $_GET["term"]; ?>');
$('#searchinput').val('<?php echo $_GET["query"]; ?>');
<?php endif; ?>
$('#dtBasicExample tbody tr').click( function() {
var criminalid = $(this).attr('data-criminalid');
window.location = "update.php?id="+criminalid;
})
$('.togglepanel').click(function(){
$('.sidepanel').show();
});
$('.closepanel').click(function(){
$('.sidepanel').hide();
});
});
</script>
</head>
<body>
<div class="sidepanel">
<img src="mahapol.png" />
<ul>
<li><a href="/crimelogs"><i class="fa fa-address-book"></i> Add Entry</a></li>
<li><a href="/crimelogs/search.php?term=1"><i class="fa fa-search"></i> Search Entry</a></li>
<li><a href="/crimelogs/logout.php"><i class="fa fa-times-circle"></i> Log Out</a></li>
<li><a href="#" class="closepanel">Close ×</a></li>
</ul>
</div>
<div class="container-fluid padding-left211">
<div class="pageheading"><button class="togglepanel">☰</button>Search Entry</div>
<form method="GET">
<div class="input-group-prepend">
<select class="custom-select" id="inputGroupSelect04" name="term">
<option value="name" selected>Name</option>
<option value="surname">Surname</option>
<option value="bankacc">Bank Account Number</option>
<option value="mobbank">Registered mobile no. to Bank account</option>
<option value="mobno">Mobile Number used for Calling</option>
<option value="email">Registered Email Id</option>
<option value="address">Address</option>
<option value="panno">PAN No.</option>
<option value="adhaar">Aadhar Number</option>
<option value="crime_number">Crime Number</option>
<option value="crime_year">Crime Year</option>
<option value="registration_date">Registration Date</option>
</select>
<div class="input-group">
<input type="text" class="form-control" placeholder="Enter search term" id="searchinput" name="query" style="margin-left: 10px;">
</div>
<div class="input-group-append" id="btn-search">
<button class="btn btn-search" type="button"><i class="fa fa-search" aria-hidden="true"></i></button>
</div>
</div>
</crimelogs>
<table id="dtBasicExample" class="table table-striped table-bordered table-sm table-responsive" cellspacing="0" width="100%">
<thead>
<tr>
<th class="th-sm">ID
</th>
<th class="th-sm">Name
</th>
<th class="th-sm">Surname
</th>
<th class="th-sm">Bank Account Number
</th>
<th class="th-sm">Registered mobile no. to Bank account
</th>
<th class="th-sm">Mobile Number used for Calling
</th>
<th class="th-sm">Registered Email Id
</th>
<th class="th-sm">Address
</th>
<th class="th-sm">PAN No.
</th>
<th class="th-sm">Aadhar Number
</th>
<th class="th-sm">Crime Number
</th>
<th class="th-sm">Crime Year
</th>
<th class="th-sm">Registration Date
</th>
</tr>
</thead>
<tbody>
<?php
if ($criminaldata->num_rows > 0) {
$i = 0;
while($row = $criminaldata->fetch_assoc()) {
echo '<tr data-criminalid="'.$row['criminalid'].'" title="Edit Entry">';
echo '<td>'.(++$i+($RECORDS_PER_PAGE*($pageno-1))).'</td>';
echo '<td>'.$row['name'].'</td>';
echo '<td>'.$row['surname'].'</td>';
echo '<td>'.$row['bankacc'].'</td>';
echo '<td>'.$row['mobbank'].'</td>';
echo '<td>'.$row['mobno'].'</td>';
echo '<td>'.$row['email'].'</td>';
echo '<td>'.$row['address'].'</td>';
echo '<td>'.$row['panno'].'</td>';
echo '<td>'.$row['adhaar'].'</td>';
echo '<td>'.$row['crime_number'].'</td>';
echo '<td>'.$row['crime_year'].'</td>';
echo '<td>'.$row['registration_date'].'</td>';
echo '</tr>';
}
}
?>
</tbody>
</table>
<nav aria-label="Page navigation example">
<ul class="pagination" style="justify-content: center;">
<?php if ($pageno>1):?>
<li class="page-item">
<a class="page-link" href="<?php echo $prevURL; ?>" aria-label="Previous" disabled>
<span aria-hidden="true">«</span>
<span class="sr-only">Previous</span>
</a>
</li>
<li class="page-item"><a class="page-link" href=<?php echo $prevURL; ?>><?php echo $pageno-1; ?></a></li>
<?php endif; ?>
<li class="page-item active"><a class="page-link" href="#"><?php echo $pageno; ?></a></li>
<?php if ($pageno<$totalpage):?>
<li class="page-item"><a class="page-link" href="<?php echo $nextURL; ?>"><?php echo $pageno+1; ?></a></li>
<li class="page-item">
<a class="page-link" href="<?php echo $nextURL; ?>" aria-label="Next">
<span aria-hidden="true">»</span>
<span class="sr-only">Next</span>
</a>
</li>
<?php endif; ?>
</ul>
</nav>
</div>
</body>
</html>