-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin_book.php
71 lines (68 loc) · 2.58 KB
/
admin_book.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
<!-- This page to give the employee and the manager all the list of the books
and also to the manager a chance to edit -->
<?php
// starting the session
session_start();
// the title of the page
$title = "List book";
// to reqiure pages header and function
require_once "./template/header.php";
require "./include/dBFunctions.inc.php";
$conn = db_connect();
// the function we will use is getAll to get all the books
$result = getAll($conn);
?>
<div><!-- links to enter to another page or existes -->
<a href="admin_signout.php" class="btn btn-danger"><span class="glyphicon glyphicon-off"></span> Logout</a>
<a href="admin_publishers.php" class="btn btn-primary"><span class="glyphicon glyphicon-paperclip"></span> Publishers</a>
<a href="admin_categories.php" class="btn btn-primary"><span class="glyphicon glyphicon-list-alt"></span> Categories</a>
<?php
// if the manager is the admin , he can add a new book
if (isset($_SESSION['managers']) && $_SESSION['managers']==true){
echo '<a class="btn btn-primary" href="add_book.php"><span class="glyphicon glyphicon-plus"></span> Add Book</a>';
}
?>
</div>
<!-- The table that we will bring from the databese -->
<table class="table" style="margin-top: 20px">
<tr>
<th>ISBN</th>
<th>Title</th>
<th>Author</th>
<th>Image</th>
<th>Description</th>
<th>Price</th>
<th>Publisher</th>
<th>Category</th>
<th> </th>
<th> </th>
</tr><!-- loop for bringing all the data -->
<?php while($row = mysqli_fetch_assoc($result)){ ?>
<tr><!-- the rows in the database -->
<td><?php echo $row['PID']; ?></td>
<td><?php echo $row['Title']; ?></td>
<td><?php echo $row['Author_name']; ?></td>
<td><?php echo $row['Image_path']; ?></td>
<td><?php echo $row['descriptions']; ?></td>
<td><?php echo $row['Price']; ?></td>
<td><?php echo getPubName($conn, $row['publisher_id']); ?></td>
<td><?php echo getCatName($conn, $row['Category']); ?></td>
<?php // every manager can edit or delete a book from the list
if(isset($_SESSION['managers']) && $_SESSION['managers']==true){
echo '<td><a href="admin_edit.php?PID=';
echo $row['PID'];
echo'"><span class="glyphicon glyphicon-pencil"></span>Edit</a></td>';
}else if (isset($_SESSION['managers']) && $_SESSION['managers']==true){
echo '<td><a href="admin_delete.php?PID=';
echo $row['PID'];
echo '"><span class="glyphicon glyphicon-trash"></span>Delete</a></td>';
}
?>
</tr>
<?php } ?>
</table>
<?php
if(isset($conn)) {mysqli_close($conn);}
require_once "./template/footer.php";
exit();
?>