-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
122 lines (116 loc) · 2.68 KB
/
index.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
<?php
include 'koneksi.php';
session_start();
$sql = "SELECT * FROM vwBuku";
$result = mysqli_query($conn,$sql);
$isadmin=false;
$isuser=false;
if (isset($_SESSION["status"])){
if ($_SESSION["status"]=="ADMIN"){
$isadmin=true;
}elseif ($_SESSION["status"]=="USER") {
$isuser=true;
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="css/index.css">
<title>Perpustakan Kita</title>
</head>
<body>
<a href="/bookstore/BookStore"><h1 align="center">PERPUSTAKAAN KITA</h1></a>
<ul>
<li style="float:left"><a href="/bookstore/BookStore">Home</a></li>
<li>
<?php
if (!(isset($_SESSION["username"]))){
?>
<a href="login.php" style="float:right;">Login</a>
<a href="singup.php" style="float:right;">Daftar</a>
<?php
}else{
?>
<?php
if ($isuser){
?>
<a href="listpinjam.php" style="float:left;">Daftar Buku</a>
<?php
};
?>
<a href="logout.php" style="float:right;">Logout</a>
<?php
};
?>
</li>
</ul>
<table>
<tr class="header">
<td class="column">No</td>
<td class="column">ISBN</td>
<td class="column">Judul</td>
<td class="column">Pengarang</td>
<td class="column">Penerbit</td>
<td class="column">Tahun Terbit</td>
<td class="column">Tersedia</td>
<?php
if ($isadmin){
?>
<td class="column" colspan="2">Edit/Hapus</td>
<?php
}
?>
<?php
if ($isuser){
?>
<td class="column">Pinjam</td>
<?php
}
?>
</tr>
<?php
$no=1;
while($data = mysqli_fetch_assoc($result)){
?>
<tr>
<td><?=$no++?></td>
<td><?=$data['isbn']?></td>
<td><a href="detail.php?id=<?=$data['isbn']?>"><?=$data['judul']?></a></td>
<td><?=$data['pengarang']?></td>
<td><?=$data['nama_instansi']?></td>
<td><?=$data['tahun_terbit']?></td>
<td><?=($data['jumlah'])?'Yes':'No'?></td>
<?php
if ($isadmin){
?>
<td><a href="">edit</a></td>
<td><a href="">hapus</a></td>
<?php
}
?>
<?php
if ($isuser){
?>
<?php
if ($data["jumlah"]){
?>
<td><a href="pinjam.php?isbn=<?=$data["isbn"]?>">Pinjam</a></td>
<?php
}else{
?>
<td>Kosong</td>
<?php
}
?>
<?php
}
?>
</tr>
<?php } ?>
</table>
</body>
</html>