Show Code:
artist-detail.php
<?php include 'session.php'; ?>
<!DOCTYPE html>
<html>
<head>
<title>Alexandria</title>
<link href="style1.css" rel="stylesheet" type="text/css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<?php include 'nav.php'; ?>
<?php include 'db-connect.php'; ?>
<?php
$artist_id=$_GET['artist_id'];
$sql='SELECT * FROM t_artists WHERE artist_id='.$artist_id;
$result=mysqli_query($con,$sql);
$row=mysqli_fetch_array($result);
?>
<main id="detail">
<article>
<?php
echo '<h2>'.htmlentities($row['artist_name']).'</h2>';
echo '<h3>' ;
//handle BC for artist dates before year 0
if($row['year_birth']>=0){
echo $row['year_birth'].' - ';
//handle living artists
if($row['year_death']>0){
echo $row['year_death'];
}
else{
echo 'present';
}
}
else{
echo $row['year_birth']*(-1).'BC - '.$row['year_death']*(-1).'BC';
}
echo '</h3>' ;
?>
<?php echo $row['artist_biography']; ?>
</article>
<?php
echo '<figure>';
echo '<img src="'.$row['artist_image'].'">';
echo '</figure>';
?>
<h1>Associated Artworks:</h1>
<div id="piece-container">
<?php
$sql="SELECT * FROM t_pieces JOIN t_artists ON artist_fk=artist_id WHERE artist_id=".$artist_id;
$result=mysqli_query($con,$sql);
while ($row = mysqli_fetch_array($result)) {
echo '<div id="piece">';
echo '<img src="' . $row['piece_image'] . '">';
echo '<section>';
echo '<h2>' . $row['piece_name'] . '</h2>';
echo '<span>' . $row['artist_name'] . '</span>';
echo '<br><span>' . $row['medium_name'] . '</span><br>';
echo '<a href="process-favourite.php?piece_id=' . $row['piece_id'] . '"><img src="icons/favourite.png"></a>';
echo '<a href="piece-update.php?piece_id=' . $row['piece_id'] . '"><img src="icons/update.png"></a>';
echo '<a href="piece-delete.php?piece_id=' . $row['piece_id'] . '"><img src="icons/delete.png"></a>';
echo '</section>';
echo '</div>';
}
?>
</div>
<?php mysqli_close($con); //Close Connection?>
</main>
</body>
</html>