-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSearch_book.php
More file actions
139 lines (136 loc) · 3.48 KB
/
Search_book.php
File metadata and controls
139 lines (136 loc) · 3.48 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
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
<?php
session_start();
if(isset($_REQUEST["logout"]))
{
session_unset();
session_destroy();
echo "<script>
location.href='admin.html';
</script>";
}
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>List of Books</title>
<link rel="stylesheet" href="Search_book.css">
<style type="text/css">
body{
background-image: url("1.jpg");
background-repeat: no-repeat;
background-position: center;
background-size: cover;
height: 100vh;
}
.tab
{
border-collapse: collapse;
}
.t1{
margin-top: 1%;
text-align: center;
}
tr{
text-align: center;
}
td,th{
margin: 2%;
padding: 1%;
width: 150px;
height: 30px;
}
#padd{
padding: 00px;
float: right;
}
</style>
</head>
<body>
<ul>
<li><a href="Home.php">Home</a></li>
<li><a href="Search_book.php" class="home">Find a Book</a></li>
<li><a href="Update_book.php">Update Book's record</a></li>
<li><a href="Insert_book.php" >Add Book in record</a></li>
<li><a href="Delete_book.php">Delete book from record</a></li>
<li id="padd"> <form class="" action="" method="post">
<a href=""><input id="button" type="submit" name="logout" value="Logout"></a>
</form></li>
</ul>
<div class="heading">
<header>
<h2>Search a Book from Record..</h2>
</header>
<form class="" action="" method="post">
<input type="text" name="search" placeholder="Enter a Book Id...">
<input type="submit" name="search1" value="Search">
</form>
</div>
</body>
</html>
<?php
if(isset($_REQUEST["search1"]))
{
echo "<h3 class='t1'>Searched Book</h3>";
echo "<table border='1' align='center' class='tab'>";
echo "<tr>
<th>Book Id</th>
<th>Book Name</th>
<th>Author Name</th>
<th>Publisher</th>
<th>Cost</th>
<th>Quantity</th>
</tr>";
$id=$_POST["search"];
// $name=$_POST["bookname"];
// $Aname=$_POST["authorname"];
// $price=$_POST["price"];
$con=new mysqli("localhost","root","Harshil479","library_project");
$sql="select * from books where id='$id'";
if($result=mysqli_query($con,$sql))
{
while($row=mysqli_fetch_row($result))
{
echo "<tr>
<td>$row[0]</td>
<td>$row[1]</td>
<td>$row[2]</td>
<td>$row[3]</td>
<td>$row[4]</td>
<td>$row[5]</td>
</tr>";
}
}
echo "</table>";
}
else
{
echo "<h3 class='t1'>List of Available Books in Record</h3>";
$con=new mysqli("localhost","root","Harshil479","library_project");
$sql="select * from books";
echo "<table border='1' align='center' class='tab'>";
echo "<tr>
<th>Book Id</th>
<th>Book Name</th>
<th>Author Name</th>
<th>Publisher</th>
<th>Cost</th>
<th>Quantity</th>
</tr>";
if($result=mysqli_query($con,$sql))
{
while($row=mysqli_fetch_row($result))
{
echo "<tr>
<td>$row[0]</td>
<td>$row[1]</td>
<td>$row[2]</td>
<td>$row[3]</td>
<td>$row[4]</td>
<td>$row[5]</td>
</tr>";
}
}
echo "</table>";
}
?>