-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsearch.php
More file actions
35 lines (32 loc) · 1.01 KB
/
search.php
File metadata and controls
35 lines (32 loc) · 1.01 KB
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
<?php
include("include/header.php");
include("include/config.php");
?>
<div class="container">
<?php
if(isset($_POST['submit'])) {
$search = mysqli_real_escape_string($conn, $_POST['search']);
$sql = "SELECT * FROM book WHERE title LIKE '%$search%' OR author LIKE '%$search%'";
$result = mysqli_query($conn, $sql);
$queryResult = mysqli_num_rows($result);
echo"There are ".$queryResult." results!";
if($queryResult > 0){
while($row = mysqli_fetch_assoc($result)) { ?>
<ul>
<li>
<i class="tiny material-icons prefix" style="top:10px">book</i>
<a href="<?php echo $row["link"];?>">
<h5 class="black-text"><?php echo $row["title"];?> - <?php echo $row["author"];?> </h5> </a>
</li>
</ul>
<?php
}
} else {
echo "There are no results matching your search! Would you like to request a book? Chat with us";
}
}
?>
</div>
<?php
include('include/footer.php');
?>