-
Notifications
You must be signed in to change notification settings - Fork 0
/
PageBook.php
172 lines (121 loc) · 4.3 KB
/
PageBook.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<!DOCTYPE html>
<html lang="en">
<?php
session_start();
?>
<head>
<title>STARTSAW</title>
<meta charset="utf-8">
<!-- icon webpage ----------------------------------------->
<link rel="icon" href="favicon.ico" type="image" sizes="16x16">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet" type="text/css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" media="all" href="css/footer.css" />
<link rel="stylesheet" media="all" href="css/common.css" />
<link rel="stylesheet" media="all" href="css/bookPage.css" />
<link rel="stylesheet" media="all" href="css/home.css" />
<script src="js/common.js"></script>
<?php
if(isset($_SESSION['username'])) {
echo '<script src="js/message_updates.js"></script>';
}
?>
</head>
<body>
<?php
require "navbar.php";
?>
<div id="contentBookPage">
<?php
require "db/mysql_credentials.php";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
if(isset($_GET['Id']))
$id = $_GET['Id'];
else
$id = 0;
$_SESSION['PrevPage']="PageBook.php?Id=".$id;
$sql = "SELECT *, book.description as BookDesc FROM book, insertion
WHERE insertion.Material_offered = book.ID and book.ID='$id'";
$result = mySQLi_query($conn, $sql) or die("Error query");
while($row = mySQLi_fetch_array($result)){
echo"
<div id='BookCover'>
<img src='data:image/jpeg;base64,".base64_encode($row['Cover'])."' alt='cover'/>
</div>
<div id='BookDescription'>
<div id='Title'><p>".$row['Title']."</p></div>
<div id='Author'><p>by ".$row['Author']."</p></div>
<div id='Text'>
<p>".$row['BookDesc']."</p>
</div>
</div>
<div id='SellerInfo'>
<div id='Seller'>
<h5> Sold By: </h5>
<a href='show_profile.php?user=".$row['User_offerer']."&page=1'>
".$row['User_offerer']."
</a>
</div>
<br><br>
<div id='Seller'><h5>Price: </h5><p>".$row['Price']." €</p></div>
<br><br>
<div id='Seller'><h5>Place: </h5><p>".$row['Place']."</p></div>
<br><br><br><br>";
#Check if logged
$star_status="glyphicon glyphicon-star-empty";
$link = "login.php";
if(isset($_SESSION['username'])){
$user = $_SESSION['username'];
#Check if in wishlist
$sql2 = "SELECT COUNT(*) as IsThere FROM wishlist WHERE Book='$id' and Username='$user';";
$result2 = mySQLi_query($conn, $sql2) or die("Error query");
#If is in list -> change calss for star icon
while($row2 = mySQLi_fetch_array($result2)){
if($row2['IsThere'] == 1)
$star_status="glyphicon glyphicon-star";
}
$link="script/add_favourite.php?Book=".$id;
}
echo"
<div class='AddFavourite'>
<a href='".$link."'><i class='$star_status'></i></a><p> Add Favourite</p>
</div>
</div>
<div id='Details'>
<h2>Details</h2>
<div class='Info'><h5>Paperback: </h5><p>".$row['PageNum']." pages</p></div>
<div class='Info'><h5>Publisher: </h5><p>".$row['Edition']."</p></div>
<div class='Info'><h5>ISBN: </h5><p>".$row['ISBN']."</p></div>
";
$sql2 = "SELECT faculty.name as Fac, category.Name as Cat
FROM book, concern, category, faculty
WHERE book.ID = concern.Book and concern.Category = category.ID
and book.ID='".$id."' and faculty.ID = category.Faculty";
$result2 = mySQLi_query($conn, $sql2) or die("Error query2");
while($row2 = mySQLi_fetch_array($result2)){
echo"
<div class='Info'>
<h5>Category: </h5>
<p>
<a href='#'>".$row2['Fac']."</a>
>>
".$row2['Cat']."
</p>
</div>";
}
echo"</div>";
}//end while(mySQLi_fetch_array)
?>
</div><!-- end contentBookPage -->
<!-- FOOTER ----------------------------------------->
<?php
require "footer.php";
?>
</body>
</html>