-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwishlist.php
144 lines (127 loc) · 4.9 KB
/
wishlist.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
<?php
/**
* Created by PhpStorm.
* User: beeker
* Date: 2019-04-15
* Time: 16:55
*/
require_once 'db-connect.php';
$genreId = $_GET['id'];
session_start();
unset($_SESSION['wish']);
unset($_SESSION['cart']);
$email = $_SESSION['email'];
if (!$email) {
header("Location: login.html");
die();
}
$queryString = 'CREATE TABLE FilteredUC(cemail varchar(225), isbn char(16), PRIMARY KEY(cemail, isbn));';
$myConn->set_query_string($queryString);
$result = $myConn->execute_query();
$queryString = "INSERT INTO FilteredUC (cemail, isbn) SELECT email, isbn FROM tblUserCartXref ucx WHERE ucx.email = '$email';";
$myConn->set_query_string($queryString);
$result = $myConn->execute_query();
$queryString = 'SELECT b.isbn, b.title, b.price, b.pubDate, b.imageFilename, a.compositeName, fuc.cemail FROM tblBooks b' .
' LEFT JOIN tblBooksAuthorsXref bax on b.isbn = bax.isbn LEFT JOIN tblAuthors a on bax.authorId = a.authorId' .
' LEFT JOIN tblUserWishXref uwx on uwx.isbn = b.isbn LEFT JOIN tblUser u on uwx.email = u.email' .
' LEFT JOIN FilteredUC fuc ON fuc.isbn = b.isbn' .
" WHERE u.email = '$email' ORDER BY title;";
$myConn->set_query_string($queryString);
$result = $myConn->execute_query();
if (!$result)
die ('The query failed for some reason');
$books = $myConn->get_first_result(RETURN_OBJECT);
$num_rows = $myConn->get_number_of_returned_rows();
session_start();
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Volga/Wishlist</title>
<link href="style.css" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Raleway:400,600,800" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,600" rel="stylesheet">
</head>
<body>
<div class="inner">
<form class="left" id="searchBar" method="post" action="books.php">
<input class="left" type="text" name="muse" id="search"/>
<select class="left" id="searchOptions" name="category" size="1">
<option selected>Title</option>
<option>Author</option>
<option>Isbn</option>
</select>
<input class="left" type="submit" id="searchButton" value="SEARCH"/>
</form>
<p class="account right"><?php
if (!$_SESSION['name']) {
echo '<a class="login" href="login.html">Login</a>';
} else {
echo 'Hello, ' . $_SESSION['name'] . "     <a class='login' href='cart.php'>Cart</a>     <a class='login' href='wishlist.php'>Wishlist</a>     <a class='login' href='logout.php?href=index.php'>Logout</a>";
}
?>
</p>
<a id="logo" href="index.php">
<h1>Volga</h1>
</a>
</div>
<header>
<nav class="inner">
<!-- Start nav list-->
<ul>
<li>
<a href="index.php">
Home
</a>
</li><li>
<a href="books.php">
Books
</a>
</li><li>
<a href="get-genres.php">
Genres
</a>
</li>
</ul><!-- End nav list -->
</nav>
</header>
<!-- Start inner Div -->
<div class="inner">
<h1><?php echo $_SESSION['name'] . '\'s wishlist'; ?></h1>
<?php
if ($num_rows <= 0) {
echo '<h3 style="text-align:center;margin-top:60px;">There are no books in your wishlist</h3>';
}
for ($i = 0; $i < $num_rows; $i++) {
if ($i != 0) {
echo '<div class="spacer"></div>';
}
echo '<a href="book.php?isbn=' . $books->isbn . '">
<div class="wishLog">
<img class="bookCover left" src="images/books/' . $books->imageFilename . '" alt="The Cover for ' . $books->title . '" width="120">
<div class="details left">
<h3 style="font-size:20px; line-height:25px; margin-top:20px;"><em>TITLE</em><br>' .
$books->title .
'</h3>';
echo '</div>
<div class="purcahseButtons left">
<h2 class="logPrice">$' . sprintf("%.2f", $books->price) . '</h2>';
if (!$books->cemail) {
echo '<a href="addcart.php?href=wishlist.php&isbn=' . $books->isbn . '" class="addCart">Add To Cart</a>';
} else {
echo '<a href="removecart.php?href=wishlist.php&isbn=' . $books->isbn . '" class="addCart" style="font-size:15px">Remove From Cart</a>';
}
echo '<a href="removewishlist.php?href=wishlist.php&isbn=' . $books->isbn . '" class="addWish" style="font-size:12px;">Remove from Wishlist</a>
</div>
</div>
</a>';
$books = $myConn->get_next_result(RETURN_OBJECT);
}
$queryString = 'DROP TABLE FilteredUC;';
$myConn->set_query_string($queryString);
$result = $myConn->execute_query();
?>
</div><!-- End inner -->
</body>
</html>