-
Notifications
You must be signed in to change notification settings - Fork 0
/
artist-gallery-portfolio.php
246 lines (195 loc) · 10.8 KB
/
artist-gallery-portfolio.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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
<?php
session_start();
if (isset($_SESSION["user_id"])) {
// create a database connection
$mysqli = require __DIR__ . "/database.php";
// get the user's email address
$sql = "SELECT * FROM users
WHERE id = {$_SESSION["user_id"]}";
$result = $mysqli->query($sql);
$user = $result->fetch_assoc();
if ($user["isArtist"] == "yes") {
$_SESSION["isArtist"] = true;
$_SESSION["user_id"] = $user["id"];
header("Location: artist-dashboard.php");
}
}
?>
<?php
// fetch the details of the user whose id is in the URL from users table
$sql = "SELECT * FROM users
WHERE id = {$_GET["id"]}";
$result = $mysqli->query($sql);
$artist = $result->fetch_assoc();
// fetch the artist details of the artist whose id is in the URL from artist_details table
$sql = "SELECT * FROM artist_details
WHERE artist_id = {$_GET["id"]}";
$detail_result = $mysqli->query($sql);
$artist_details = $detail_result->fetch_assoc();
// fetch the number of art entries of the artist whose id is in the URL from art table
$sql = "SELECT COUNT(*) AS art_count FROM art
WHERE artist_id = {$_GET["id"]}";
$art_count_result = $mysqli->query($sql);
$art_count = $art_count_result->fetch_assoc();
// fetch the number of gallery entries of the artist whose id is in the URL from art table
$sql = "SELECT COUNT(*) AS gallery_count FROM galleries
WHERE artist_id = {$_GET["id"]}";
$gallery_count_result = $mysqli->query($sql);
$gallery_count = $gallery_count_result->fetch_assoc();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset='UTF-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<title><?= $artist['name'] ?>'s Portfolio</title>
<!-- Styling imports -->
<link rel='stylesheet' href='styles/main.css'>
<link rel='stylesheet' href='styles/utility.css'>
<!-- Bootstrap Icons imports -->
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css'>
<!-- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css"> -->
</head>
<body>
<?php include __DIR__ . "/navbar.php"; ?>
<!-- Start of main -->
<main>
<div class='container-cart'>
<div class='row'>
<div class='col-md-12 col-lg-12'>
<div class='d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom'>
<!-- display the artist's profile image in a row with the artist name -->
<div class='row'>
<div class='col-md-3 col-lg-3 p-3'>
<img src='<?= $artist_details['profile_image'] ?>' alt='<?= $artist['name'] ?>' class='card-img-top'>
</div>
<div class='col-md-9 col-lg-9'>
<div class='row px-2'>
<div class='col-md-5 col-lg-5'>
<h1 class='fs-1 p-2'>
<?= $artist['name'] ?>
</h1>
<div class='row justify-content-between'>
<span class='col-5 badge badge-imperial'>
<?= $art_count['art_count'] ?> <?= $art_count['art_count'] == 1 ? " Art Piece" : "Art Pieces" ?>
</span>
<span class='col-5 badge badge-imperial'>
<?= $gallery_count['gallery_count'] ?> <?= $gallery_count['gallery_count'] == 1 ? "Gallery" : "Galleries" ?>
</span>
</div>
</div>
<div class='col-md-7 col-lg-7 px-3'>
<p class='fs-5'>
<?= $artist_details['story'] ?>
</p>
<p class='fs-5'>
<?= $artist_details['artist_name'] ?> works on the art that he does from <?= $artist_details['building'] ?> on <?= $artist_details['street'] ?>, <?= $artist_details['town'] ?>, <?= $artist_details['county'] ?> in Kenya.
<br />
<br />
This artist has been with us since <?php
$date = date_create($artist_details['created_at']);
echo date_format($date, 'F j, Y');
?>.
</p>
</div>
</div>
</div>
</div>
</div>
<hr class='mobile-hide hr' />
</div>
</div>
</div>
<div class='container-flex' style='padding-left:7%; padding-right:8%;'>
<div class='row'>
<!-- Start of aside navbar -->
<nav class='col-md-3 col-lg-2 d-md-block'>
<div class='position-sticky pt-3 background-cultured'>
<ul class='nav flex-column'>
<li class='nav-item'>
<a class='nav-link' href='artist-portfolio.php?id=<?= $artist['id'] ?>'>
<i class='bi bi-postage-heart-fill' style='font-size: 22px;'></i>
Art
</a>
</li>
<li class='nav-item'>
<a class='nav-link active' aria-current='page' href='#'>
<i class='bi bi-ticket-perforated-fill' style='font-size: 22px;'></i>
Galleries
</a>
</li>
</ul>
</div>
</nav>
<!-- End of aside navbar -->
<div class='col-md-9 col-lg-10'>
<div class='row p-2'>
<!-- Fetch all the gallery record entries by the artist who is logged in -->
<!-- Render a card for each gallery -->
<?php
$mysqli = require __DIR__ . '/database.php';
$fetch_stmt = "SELECT * FROM galleries WHERE artist_id = {$artist['id']}";
$result = $mysqli->query($fetch_stmt);
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
$gallery_id = $row['id'];
$gallery_name = $row['title'];
$gallery_location = $row['location'];
$gallery_story = $row['story'];
$gallery_fee = $row['fee'];
$gallery_date = $row['date'];
$gallery_imgDir = $row['coverImg'];
?>
<div class='col-lg-6 col-md-12 p-3'>
<div class='card mb-3'>
<div class='row'>
<div class='col-md-4'>
<img src='<?= $gallery_imgDir ?>' class='card-img-top' alt='<? $gallery_name ?>'>
</div>
<div class='col-md-8 px-5'>
<div class='card-body'>
<h3 class='space-cadet cadet-underlined'><?= $gallery_name ?></h3>
<p class='card-text'>
<i class='bi bi-geo-fill manatee' style='font-size:22px;'></i>
<?= $gallery_location ?>
</p>
<p class='card-text'>
<i class='bi bi-lightbulb-fill manatee' style='font-size:22px;'></i>
<?= $gallery_story ?>
</p>
<p class='card-text'>
<i class='bi bi-cash-coin manatee' style='font-size:22px;'></i>
Kshs <?= $gallery_fee ?>
</p>
<p class='card-text'>
<i class='bi bi-calendar-date manatee' style='font-size:22px;'></i>
<?php
$date = date_create($gallery_date);
echo date_format($date, 'F j, Y');
?>
</p>
<center>
<a href='gallery-details.php?id=<?= $gallery_id ?>' class='btn btn-imperial'>
View gallery
</a>
</center>
</div>
</div>
</div>
</div>
</div>
<?php
}
} else {
echo "<center class='fs-5 mt-6 imperial-red'>" . $artist_details['artist_name'] . " has no galleries yet. Come back later. </center>";
}
?>
</div>
</div>
</div>
</div>
</main>
<!-- End of main -->
</body>
</html>