-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.php
245 lines (226 loc) · 7.71 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
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
<?php
$conn=mysqli_connect('localhost','root','','notes');
if($conn){
//echo "Connected successfully";
} else{
die("Couldn't connect");
}
if($_GET['id']){
$page=$_GET['id'];
} else{
$page=1;
}
$per_page=10;
$offset=($page-1)*$per_page;
$search=$_GET['key'];
$sql="select * from notes where Description like '%$search%'";
$query=mysqli_query($conn,$sql);
$sql2="select * from notes where Description like '%$search%' limit $offset , $per_page";
$query2=mysqli_query($conn,$sql2);
$number_of_pages=(ceil(mysqli_num_rows($query)/$per_page));
if($page==$number_of_pages){
$next=1;
} else{
$next=$page+1;
}
if($page==1){
$prev=$number_of_pages;
} else{
$prev=$page-1;
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>iNotes</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css" integrity="sha512-MV7K8+y+gLIBoVD59lQIYicR65iaqukzvf/nwasF0nqhPay5w/9lJmVM2hMDcnK1OnMGCdVK+iQrJ7lzPJQd1w==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<style>
a{
text-decoration: none;
}
a:hover{
text-decoration: underline;
}
.element{
background-color:rgb(186, 214, 233);
color:rgb(0, 0, 0);
padding-bottom:5px;
padding-inline: 7px;
border-radius: 2px;
}
.element:nth-child(even){
background-color:rgb(113, 146, 160);
color:white;
}
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/typed.js/2.0.12/typed.min.js"></script>
</head>
<body style="font-family:georgia;">
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
<div class="container-fluid ms-5">
<a class="navbar-brand" href="#">
<img src="./images/logo.png" alt="Logo" width="30" height="24" class="d-inline-block align-text-top">
<span class="name"></span>
<script>
new Typed('.name',{
strings: ['iNotes'],
typeSpeed: 400,
});
</script>
</a>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ms-auto mb-2 mb-lg-0 me-5">
<li class="nav-item">
<a class="nav-link" aria-current="page" href="index.php">Home</a>
</li>
<li class="nav-item">
<a class="nav-link active" href="data.php">Notes</a>
</li>
</div>
</div>
</nav>
<br/>
<br/>
<br/>
<table class="table table-striped table-class mx-auto w-75 mb-5" id= "table-id">
<thead>
<tr>
<th class="text-center">Sr. No.</th>
<th class="text-center">Title</th>
<th class="text-center">Description</th>
<th class="text-center">TimeStamp</th>
<th class="text-center">Action</th>
</tr>
</thead>
<tbody>
<?php
for($i=1;$i<=mysqli_num_rows($query2);$i++){
$data=mysqli_fetch_assoc($query2); ?>
<tr>
<td style="text-align: center;"><?php echo $i+$offset; ?></td>
<td style="text-align: center;"><?php echo $data['Title'];?></td>
<td style="text-align: center;"><?php echo $data['Description'];?></td>
<td style="text-align: center;"><?php echo $data['TimeStamp'];?></td>
<td style="text-align: center;">
<a href="edit.php?id=<?php echo $data['sno']; ?>">Edit</a> ||
<a href="delete.php?id=<?php echo $data['sno']; ?>">Delete</a>
<td>
</tr>
<?php
}
?>
</tbody>
</table>
<div class="container d-flex mb-5">
<div class="element">
<a href="search.php?key=<?php echo $search; ?>&&id=<?php echo $prev; ?>"style="color:black;">← Previous</a>
</div>
<?php
for($i=1;$i<=$number_of_pages;$i++){
?>
<div class="element">
<a href="search.php?key=<?php echo $search; ?>&&id=<?php echo $i; ?>" style="color:black;"><?php echo $i; ?></a>
</div>
<?php
}
?>
<div class="element">
<a href="search.php?key=<?php echo $search; ?>&&id=<?php echo $next; ?>"style="color:black;">Next →</a>
</div>
</div>
<div>
<!-- Footer -->
<footer class="bg-dark text-center text-white">
<!-- Grid container -->
<div class="container p-4">
<!-- Section: Social media -->
<section class="mb-4">
<!-- Facebook -->
<a class="btn btn-outline-light btn-floating m-1" href="facebook.com" role="button"target="_blank">
<i class="fab fa-facebook-f"></i>
</a>
<!-- Twitter -->
<a class="btn btn-outline-light btn-floating m-1" href="https://twitter.com/aurbtaokuch" role="button"target="_blank">
<i class="fab fa-twitter"></i>
</a>
<!-- Google -->
<a class="btn btn-outline-light btn-floating m-1" href="mailto:[email protected]" role="button"target="_blank">
<i class="fab fa-google"></i>
</a>
<!-- Instagram -->
<a class="btn btn-outline-light btn-floating m-1" href="https://www.instagram.com/its._me_.anonymous/" role="button"target="_blank">
<i class="fab fa-instagram"></i>
</a>
<!-- Linkedin -->
<a class="btn btn-outline-light btn-floating m-1" href="https://www.linkedin.com/in/sheshank-gupta-a121a7248/" role="button"target="_blank">
<i class="fab fa-linkedin-in"></i>
</a>
<!-- Github -->
<a class="btn btn-outline-light btn-floating m-1" href="https://github.com/Sheshankgupta" role="button"target="_blank">
<i class="fab fa-github"></i>
</a>
</section>
<!-- Section: Social media -->
<!-- Section: Form -->
<section class="">
<form action="">
<!--Grid row-->
<div class="row d-flex justify-content-center">
<!--Grid column-->
<div class="col-auto">
<p class="pt-2">
<strong>Sign up for our newsletter</strong>
</p>
</div>
<!--Grid column-->
<!--Grid column-->
<div class="col-md-5 col-12">
<!-- Email input -->
<div class="form-outline form-white mb-4">
<input type="email" id="form5Example21" class="form-control" placeholder="Email here" disabled/>
</div>
</div>
<!--Grid column-->
<!--Grid column-->
<div class="col-auto">
<!-- Submit button -->
<button type="submit" class="btn btn-outline-light mb-4">
Subscribe
</button>
</div>
<!--Grid column-->
</div>
<!--Grid row-->
</form>
</section>
<!-- Section: Form -->
<!-- Section: Text -->
<section class="mb-4">
<p>
This is iNotes app to store your notes with love.
</p>
</section>
<!-- Section: Text -->
</div>
<!-- Grid container -->
<!-- Copyright -->
<div class="text-center p-3" style="background-color: rgba(0, 0, 0, 0.2);">
© <?php echo date("Y"); ?> Copyright: Sheshank Gupta
</div>
<!-- Copyright -->
</footer>
<!-- Footer -->
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
<script>
function AddUrl(){
var url=document.getElementById("MySearch");
url.action += document.getElementById("search").value;
}
</script>
</body>
</html>