-
Notifications
You must be signed in to change notification settings - Fork 4
/
LoanHistory.php
56 lines (49 loc) · 1.45 KB
/
LoanHistory.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
<html>
<head>
<meta charset="utf-8">
<title>History of Loans</title>
<link href="styles.css" media="all" rel="Stylesheet" type="text/css"/>
</head>
<body>
<div class="sect1">
<h1>List of Loans</h1>
<?php
$dbconn = pg_connect("host=localhost port=5432 dbname=Sharing user=postgres password=postgres")
or die('Could not connect: HERE' . pg_last_error());
?>
<?php
session_start();
$user = $_SESSION['user'];
$query = "SELECT o.itemname, l.returnDate, l.borrowDate, l.owner FROM object o, loan l WHERE l.borrower = '".$user."' AND l.productID = o.productID";
$result = pg_query($query) or die('Query failed: ' . pg_last_error());
echo "<table border=\"1\" style=\"width:80%\" align=\"center\">
<col width=\"40%\">
<col width=\"20%\">
<col width=\"20%\">
<col width=\"20%\">
<tr>
<th>Item Name</th>
<th>Return Date</th>
<th>Borrowed Date</th>
<th>Owner</th>
</tr>";
while($row = pg_fetch_row($result)){
echo "<tr>";
echo "<td>" . $row[0] . "</td>";
echo "<td>" . $row[1] . "</td>";
echo "<td>" . $row[2] . "</td>";
echo "<td>" . $row[3] . "</td>";
echo "</tr>";
}
echo"</table>";
pg_free_result($result);
?>
<?php
pg_close($dbconn);
?>
<br>
Copyright © VYMMS<br>
<a href="AccountPage.php">Back to Account Page</a>
</div>
</body>
</html>