-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathborrowed_Books.php
140 lines (127 loc) · 4.78 KB
/
borrowed_Books.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
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
140
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width = device-width, initial-scale = 1">
<title>NTUA Library User Interface!</title>
<link rel="stylesheet" href="css/main.css">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
</head>
<body>
<section class="main-container">
<article class="index-intro">
<div class="container">
<div class="jumbotron">
<div class="row">
<div class="col-sm-4">
<h2 class="text-white">Welcome to the National Technical University of Athens Library</h2>
</div>
<div class="col-sm-4"></div>
</div>
</div>
</div>
</article>
</section>
<div class="container">
<!-- Basic vertical menu -->
<ul class="nav nav-pills">
<li class="active"><a href="index.html">Home</a></li>
<!-- Add drop down menu -->
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Books
<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="insert_Book.html">Insert Book</a></li>
<li><a href="delete_Book.html">Delete Book</a></li>
<li><a href="update_Book.html">Update Book</a></li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Members
<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="insert_member.html">Insert Member</a></li>
<li><a href="delete_member.html">Delete Member</a></li>
<li><a href="update_member.html">Update Member</a></li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Authors
<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="insert_author.html">Insert Author</a></li>
<li><a href="delete_author.html">Delete Author</a></li>
<li><a href="update_author.html">Update Author</a></li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Views
<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="oldest_books.php">Oldest Books</a></li>
<li><a href="members_names.php">Members Names</a></li>
<li><a href="author_list.php">Author List</a></li>
<li><a href="all_books.php">All Books</a></li>
</ul>
</li>
<li><a href="search_Book.html">Search</a></li>
<li><a href="queries_menu.html">Go to Queries Menu</a></li>
</ul>
<?php
$servername = "localhost";
$username = "root";
$password = "hmysqlg@m31";
$dbname = "mydb";
$db = new mysqli($servername, $username, $password, $dbname);
if($db->connect_errno > 0){
die('Unable to connect to database [' . $db->connect_error . ']');
}
$sql = '
SELECT borrows_member_copies.ISBN, Book.title, borrows_member_copies.memberID, borrows_member_copies.MFirst, borrows_member_copies.MLast FROM (
SELECT borrows_member.ISBN, borrows_member.memberID, borrows_member.MFirst, borrows_member.MLast FROM (
SELECT ISBN,member.memberID, member.MFirst, member.MLast, copyNr FROM borrows JOIN member
ON borrows.memberID = member.memberID
) as borrows_member
JOIN copies ON borrows_member.ISBN = copies.ISBN and borrows_member.copyNr = copies.copyNr
) as borrows_member_copies
JOIN Book ON borrows_member_copies.ISBN = Book.ISBN;
';
if(!$result = $db->query($sql)){
die('There was an error running the query [' . $db->error . ']');
}
$i++;
?>
<div class="container">
<h2>Borrowed Books</h2>
<table class="table table-condensed">
<thead>
<tr>
<th>#</th>
<th>ISBN</th>
<th>Title</th>
<th>memberID</th>
<th>First Name</th>
<th>Last Name</th>
</tr>
</thead>
<?php while($row = $result->fetch_assoc()){?>
<tbody>
<tr>
<td><?php echo $i ?></td>
<td><?php echo $row['ISBN']?></td>
<td><?php echo $row['title']?></td>
<td><?php echo $row['memberID']?></td>
<td><?php echo $row['MFirst']?></td>
<td><?php echo $row['MLast']?></td>
</tr>
</tbody>
<?php $i++;}?>
</table>
</div>
</body>
</html>