-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhistory.php
59 lines (55 loc) · 2.19 KB
/
history.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
<?php
session_start();
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<script>
</script>
</head>
<body>
<h1 align="center"> Library Management</h1>
<?php include 'navigation.php'; ?>
<div style="margin-left:15%;padding:1px 16px;height:100px;">
<form method=post action='#' >
<label for="name">Card No:</label></br>
<input type="text" name="cardNo" class="textBox" value=<?php echo $_POST['cardNo'];?>></br>
<input type="submit" value="Check" name="check" class="button">
</form>
</div>
<?php
if(isset($_POST['check']))
{
//echo "<div style='margin-left:15%;padding:1px 16px;'>here</div>";
$hostname="localhost";
$database="libraryManagement";
$username="root";
$password="root";
$conn = mysqli_connect($hostname, $username, $password,$database);
if (!$conn)
{
die("Connection failed: " . mysqli_connect_error());
}
else
{
//echo "<div style='margin-left:15%;padding:1px 16px;'>here".$_POST['cardNo']."</div>";
$sqlSearch="SELECT DISTINCT(Book_loans.Isbn) as Isbn, BOOK.Title as Title,Date_out ,Date_in, Fine_amt,Paid FROM `FINES`, BOOK_AUTHORS,BOOK_LOANS, BOOK,AUTHORS where FINES.Loan_id=BOOK_LOANS.Loan_id and BOOK_LOANS.Isbn=BOOK_AUTHORS.Isbn and BOOK_AUTHORS.Isbn=BOOK.Isbn AND BOOK_AUTHORS.Author_id=AUTHORS.Author_id and BOOK_LOANS.card_id=".$_POST['cardNo'];
//echo $sqlSearch;
$result = $conn->query($sqlSearch);
if ($result->num_rows > 0) {
// output data of each row
$tableData="<div style='margin-left:15%;padding:1px 16px;height:300px;'><table><tr><th>ISBN</th><th>Title</th><th>Date_out</th><th>Date_in</th><th>Fine Amount</th><th>Paid</th></tr>";
while($row = $result->fetch_assoc()) {
if($row['Paid']==1)
$tableData=$tableData."<tr><td>".$row["Isbn"]. "</td><td>" . $row["Title"]. "</td><td>".$row['Date_out']."</td><td>".$row['Date_in']."</td><td>".$row['Fine_amt']."</td><td>True</td></tr>";
else
$tableData=$tableData."<tr><td>".$row["Isbn"]. "</td><td>" . $row["Title"]. "</td><td>".$row['Date_out']."</td><td>".$row['Date_in']."</td><td>".$row['Fine_amt']."</td><td>false</td></tr>";
}
$tableData=$tableData."</table></div>";
echo $tableData;
}
}
}
?>
</body>
</html>