-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsearch_book.php
43 lines (38 loc) · 1.4 KB
/
search_book.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
<?php
$text = trim($_POST['text']);
require_once "./functions/database_functions.php";
$conn = db_connect();
$query = "SELECT * FROM books join publisher on books.publisherid=publisher.publisherid where book_isbn like'%$text%' or book_author like '%$text%' or book_title like '%$text%' or publisher_name like '%$text%' ";
$result = mysqli_query($conn, $query);
if(mysqli_num_rows($result)==0){
echo '
<div class="alert alert-warning" role="alert">
Nothing Found...
</div>' . ' <div class="search_top" >
</div>';
}else{
$number=mysqli_num_rows($result);
echo '<div class="alert alert-success" role="success"> ';
echo $number;
echo ' Books Found</div>' . ' <div class="search_top" >
</div>';
}
require_once "./template/header.php";
?>
<p class="lead text-center text-muted">Search Result</p>
<?php for($i = 0; $i < mysqli_num_rows($result); $i++){ ?>
<div class="row">
<?php while($query_row = mysqli_fetch_assoc($result)){ ?>
<div class="col-md-3">
<a href="book.php?bookisbn=<?php echo $query_row['book_isbn']; ?>">
<img class="img-responsive img-thumbnail" src="./bootstrap/img/<?php echo $query_row['book_image']; ?>">
</a>
</div>
<?php
} ?>
</div>
<?php
}
if(isset($conn)) { mysqli_close($conn); }
require_once "./template/footer.php";
?>