-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfindBook.php
103 lines (77 loc) · 2.78 KB
/
findBook.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
<!DOCTYPE html>
<html>
<head>
<title>Find A BOOK</title>
<link rel="stylesheet" href="findBook_style.css" type="text/css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<?php
$dbhost="localhost";
$username="root";
$password="";
$db="library";
$Title="";
$ISBN="";
$Author="";
$Department="";
$Section="";
$con=mysqli_connect("$dbhost","$username","$password");
mysqli_select_db($con,$db);
function getPosts()
{
$posts=array();
$posts[0]=$_POST['name'];
$posts[1]=$_POST['category'];
$posts[2]=$_POST['author'];
$posts[3]=$_POST['edition'];
return $posts;
}
if(isset($_POST['findBtn'])){
$data=getPosts();
$find_query="SELECT `Name`, `Category`, `Author`, `Edition` FROM `book` WHERE Name LIKE '$data[0]';";
$find_result=mysqli_query($con, $find_query);
if($find_result){
if(mysqli_num_rows($find_result))
{
while($row=mysqli_fetch_array($find_result))
{
$Name=$row['Name'];
$Category=$row['Category'];
$Author=$row['Author'];
$Edition=$row['Edition'];
}
echo '<script language="javascript">';
echo 'alert("Book Found")';
echo '</script>';
}else{
echo '<script language="javascript">';
echo 'alert("Book Not Found")';
echo '</script>';
}
}else{
echo "Result Error.";
}
}
?>
<form action="findBook.php" method="POST">
<div class="icon-bar">
<a href="parallax.php"><i class="fa fa-home" title="Home"></i></a>
<a href="studentRegister.php"><i class="fa fa-user-o" title="Student Registration"></i></a>
<a href="findBook.php"><i class="fa fa-search" title="Search Book"></i></a>
<a class="active" href="BorrowBook.php"><i class="fa fa-sign-out" title="Issue Book"></i></a>
<a href="returnBook.php"><i class="fa fa-sign-in" title="Return Book"></i></a>
<a href="addBook.php"><i class="fa fa-plus" title="Add Book"></i></a>
</div>
<div class="detailsDiv" align="center">
<h1 align="center" id="heading">Find Book</h1>
<label id="b">Name</label> <input type="text" id="a" name="name" required="required" value="<?php echo "$Title"; ?>"><br>
<label id="b">Category</label> <input type="text" id="a" name="category" value="<?php echo "$ISBN"; ?>"> <br>
<label id="b">Author</label> <input type="text" id="a" name="author" value="<?php echo "$Author"; ?>"><br>
<label id="b">Edition</label><input type="number" id="a" name="edition" value="<?php echo "$Department"; ?>"><br>
<button type="submit" name="findBtn" class="submit" ><span>SEARCH</span></button>
</div>
</form>
</body>
</html>