-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfavourites.php
167 lines (158 loc) · 8.93 KB
/
favourites.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
<?php
require_once "config/constants.php";
enforce_login(); // Redirect to login page if not logged in.
?>
<!DOCTYPE html>
<html lang="en">
<head>
<!-- import generic head section -->
<?php
$page_title = 'My Favourites';
include('partials/head.php');
$active_home = 'active';
?>
</head>
<body>
<?php
$firstname = $_SESSION['firstname'];
$user_id = $_SESSION['user_id']
?>
<div class="underneath-nav"></div>
<!-- import menu -->
<?php include('partials/menu.php'); ?>
<!-- Hero Section -->
<section class="hero-section small-hero pos-relative">
<div id="favourites-banner" class="flex container">
<div class="flex f-col hero-content hero-content-full-width">
<h1 class="pad-bottom-1">Favourites</h1>
<h2 class="margin-bottom-1"><?php echo $firstname ?>'s Saved Pets</h2>
<p class="pad-bottom-1">You can remember your favourite breeds or shortlist dogs by clicking the heart next to them. You can find pets that match your personality or explore your options here: </p>
<div class="btn-group pad-bottom-2">
<a href="quiz.php" class="margin-right-1 hero-btn">Personality quiz</a>
<a href="breeds.php" class="margin-right-1 hero-btn hero-btn-alt">Explore breeds</a>
<a href="dogs.php" class="hero-btn hero-btn-alt">Explore available dogs</a>
</div>
<br>
</div>
</div>
<!-- Favourite Breeds Section -->
<section id="fav-breeds" class="pg-section min-pg-section">
<h2 class="center-txt">Breeds I'm interested in</h2>
<!-- Link to dogs page, filtering on favourite breeds only -->
<?php
$pageVars = array();
$pageVars["Breed"] = get_breed_favourites();
$qs = http_build_query($pageVars);
echo "<p class='center-txt'><a class='hyperlink' style='color: var(--secondaryColor);' href='/dogs.php?" . $qs . "'>Show avaliable dogs within these breeds</a></p>";
?>
<div id="sqldata">
<!-- table for desktop -->
<table class="breeds-table2">
<thead>
<tr>
<th>Breed</th>
<th>Intelligence</th>
<th class='desktop-only'>Lifetime Cost</th>
<th class='desktop-only'>Popularity</th>
<th class="text-left">Size Class</th>
<th></th>
</tr>
<thead>
<tbody style="color: black">
<?php
$res = mysqli_query($conn, "
SELECT *
FROM dog_breeds
INNER JOIN favourite_breeds on dog_breeds.breed_id = favourite_breeds.breed_id
WHERE favourite_breeds.user_id = {$user_id}
ORDER BY Breed
");
while ($entry = mysqli_fetch_array($res)) {
$size_image = "images/icons/dog_size_" . $entry['size_class'];
?>
<!-- Start Individual Breed Row -->
<tr id='breed_id=<?php echo $entry['breed_id']; ?>'>
<td style='font-weight:bold; width:20%;' class='breed-name'>
<a href='breed-profile.php?breed_id=<?php echo $entry['breed_id']; ?>' style='color:black'><?php echo $entry['Breed']; ?></a>
</td>
<td class='desktop-only' style='width:22%;'><?php echo $entry['intelligence_desc']; ?></td>
<td class='desktop-only' class='text-center' style='width:10%;'><?php echo str_repeat(EMOJI_DOLLAR, $entry['lifetime_cost_class']); ?></td>
<td class='text-left' style='width:10%;'><?php echo str_repeat(EMOJI_STAR, $entry['popularity_class']); ?></td>
<td style='width:25%;'> <img src='images/icons/dog_size_<?php echo $entry['size_class']; ?>' alt='dog size chart' width='50%'> </td>
<td>
<form method='POST' action='/form_submissions/favourite_breed.php'>
<button type='submit' name='breed_id' value='<?php echo $entry['breed_id']; ?>'>
<img width='25%' alt='Remove from favourites' src='images/icons/x-icon.png' class="zoom-on-hover">
</button>
</form>
</td>
</tr>
<!-- End Individual Breed Row -->
<?php
}
?>
<tbody>
</table>
</div>
</section>
<!-- Favourite Dogs Section -->
<section id="fav-dogs" class="pg-section min-pg-section" style="background-color: white;">
<h2 class="center-txt" style="color: black">Dogs I'm considering adopting</h2>
<div id="sqldata">
<table class="breeds-table2">
<thead>
<tr>
<th>Name</th>
<th>Breed</th>
<th class='desktop-only'>Age</th>
<th class='desktop-only'>Gender</th>
<th>Shelter</th>
<th></th>
<th></th>
</tr>
<thead>
<tbody style="color: black">
<?php
$res = mysqli_query($conn, "
SELECT dogs.name as Dog, Breed, age, gender, shelters.name as Shelter, path, dogs.dog_id, dogs.breed_id as breed_id
FROM dogs
INNER JOIN shelters ON dogs.shelter_id = shelters.shelter_id
INNER JOIN dog_breeds ON dogs.breed_id = dog_breeds.breed_id
INNER JOIN breed_image ON dogs.breed_id = breed_image.breed_id
INNER JOIN favourite_dogs on dogs.dog_id = favourite_dogs.dog_id
WHERE owner_id IS NULL
AND main_image
AND user_id = {$user_id}
ORDER BY dogs.name
");
while ($entry = mysqli_fetch_array($res)) {
?>
<!-- Start Individual Dog Row -->
<tr id='dog_id=<?php echo $entry['dog_id']; ?>'>
<td style='width:15%;' class='dog-name'><a href='dog-profile.php?dog_id=<?php echo $entry['dog_id']; ?>'><?php echo $entry['Dog']; ?></a></td>
<td style='width:20%;' class='breed-name'><a href='breed-profile.php?breed_id=<?php echo $entry['breed_id']; ?>'><?php echo $entry['Breed']; ?></a></td>
<td class='desktop-only' style='width:10%;'><?php echo $entry['age']; ?> years</td>
<td class='desktop-only' style='width:5%;'><img src='/images/icons/<?php echo $entry['gender']; ?>.png' alt='dog image' width='20%' class="zoom-on-hover"></td>
<td style='width:20%;'><?php echo $entry['Shelter']; ?></td>
<td class='desktop-only' style='width:15%;'><img src='<?php echo SITEURL . $entry['path']; ?>' alt='dog image' width='33%'></td>
<td>
<form method='POST' action='/form_submissions/favourite_dog.php'>
<button type='submit' name='dog_id' value='<?php echo $entry['dog_id']; ?>'>
<img width='25%' alt='Remove from favourites' src='images/icons/x-icon.png' class="zoom-on-hover">
</button>
</form>
</td>
</tr>
<!-- End Individual Dog Row -->
<?php
}
mysqli_close($conn);
?>
<tbody>
</table>
</div>
</section>
<!-- FOOTER -->
<?php include('partials/footer.php'); ?>
</body>
</html>