-
Notifications
You must be signed in to change notification settings - Fork 2
/
my_books.php
130 lines (115 loc) · 3.62 KB
/
my_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
<?php
session_start();
$db = mysqli_connect('127.0.0.1', 'root', '', 'library') or die("connection failed" . mysqli_error());
if (!isset($_SESSION['username'])) {
header('location: login.php');
exit();
}
?>
<!DOCTYPE html>
<html>
<head>
<title>My Books</title>
<link rel="stylesheet" type="text/css" href="css/mybks.css">
<style>
.notification {
color: white;
padding: 5px 10px;
text-align: center;
font-family: Verdana, Geneva, Tahoma, sans-serif;
}
.notification span {
font-weight: bold;
color: red;
}
.notification b {
font-weight: bold;
color: orangered;
background: transparent;
}
</style>
</head>
<body>
<header>
<?php if(!empty($_SESSION['username'])) : ?>
<?php if(isset($_SESSION['username'])) : ?>
<?php echo '<a href="library.php" style="color: red">Home</a>'; ?>
<?php endif; ?>
<?php endif; ?>
<?php if (isset($_GET['contact']) || isset($_GET['about'])): ?>
<a href="library.php" style="color: red">Home</a>
<?php else: ?>
<a href="app/auth/authentication.php?logout=1" style="color: red">Logout</a>
<?php endif ?>
<h1>ULibrary.<small>org</small></h1>
</header>
<div class="container">
<h2>MY PACKAGES FROM ULIBRARY</h2>
<form method="POST" action="" enctype="multipart/form-data">
<table >
<thead >
<tr>
<th>N<sup>o</sup></th>
<th>Book</th>
<th>Title</th>
<th>Author</th>
<th>Refund Date</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php if (!empty($_SESSION['success'])) : ?>
<?php echo $_SESSION['success']; unset($_SESSION['success']);?>
<?php endif ?>
<?php
$user_id = $_SESSION['user_id'];
$query = "SELECT * FROM borrowed_books WHERE applicant_id = $user_id ";
$run_query = mysqli_query($db,$query);
if ($run_query) {
if(!empty($_SESSION['bk_unapproved'])) {
echo "<div class='notification'><span>Notification:</span> " . $_SESSION['bk_unapproved'] . " </div>";unset($_SESSION['bk_unapproved']);
}
if (mysqli_num_rows($run_query) >= 1) {
$rows = mysqli_fetch_all($run_query, MYSQLI_ASSOC);
foreach ($rows as $key => $row) {
$_SESSION['refund_date'] = date('d/m/Y', strtotime('+7 DAYS'));
$_SESSION['book_id'] = $row['id'];
?>
<tr>
<td><?php echo ++$key; ?></td>
<td><img src="img/<?php echo $row['image']; ?>"></td>
<td><?php echo $row['title']; ?></td>
<td><?php echo $row['author']; ?></td>
<td><?php echo $_SESSION['refund_date']; ?></td>
<td><a href='my_books.php?delete=<?php echo $_SESSION['book_id'] ?>' id="a">Remove</a></td>
</tr>
<?php } } else {
echo "<div class='empty'>BAG IS EMPTY!! GO BORROW SOME BOOKS OR WAIT FOR APPROVAL OF APPLLIED BOOKS!!</div>";
}
}
if(isset($_GET['delete'])) {
$del = $_GET['delete'];
$query = "DELETE FROM borrowed_books WHERE id = $del ";
$results = mysqli_query($db, $query);
header('location: my_books.php');
exit(0);
}
?>
</tbody>
</table>
</form>
</div>
<footer>
<p>© Created by: <i style="padding-right: 20px;"> Lab of Kn<i style="color:red;">o</i>wledge group</i>
<marquee id="marquee">Arnauld Anguh is the CEO of the Uengine Company That runs the WEB today</marquee>
<?php if (isset($_SESSION['username'])): ?>
<?php if ($_SESSION['role'] == 'admin'): ?>
<?php $id = $_SESSION['user_id']; echo "<a href='admin/index.php?role=$id'>Manage Library</a>"; ?>
<?php else: ?>
<?php echo $_SESSION['role']; ?>
<?php endif ?>
<?php endif ?>
</p>
</footer>
</body>
</html>