-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsrchBooks.php
46 lines (39 loc) · 1.14 KB
/
srchBooks.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
<?php
$srchinput=$_GET['srchinput'];
//$d="afsdfdsf";
$servername = "172.17.0.2";
$username = "admn";
$password = "Asdf@1234";
$dbname = "library";
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "SELECT bookName,bookAuthor,bookCatergory,availability FROM books WHERE bookName like '%{$srchinput}%' OR bookAuthor like '%{$srchinput}%' OR bookCatergory like '%{$srchinput}%' ";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
echo "<table class='styled-table'>
<tr>
<th>
Name
</th>
<th>
Author
</th>
<th>
Catergory
</th>
<th>
availability
</th>
</tr>";
while($row = mysqli_fetch_assoc($result)) {
echo "<tr><td style='text-align: left;'>".$row["bookName"]."</td><td>".$row["bookAuthor"]."</td><td>".$row["bookCatergory"]."</td><td>".$row["availability"]."</td></tr>";
}
echo "</table>";
} else {
echo "<h2 id='title'>No books Found</h2>";
}
mysqli_close($conn);
?>