Show Code: artists-read.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'?>
    <main>
        <div id="artist-container">
            <?php
$sql
="SELECT * FROM t_artists";

$result=mysqli_query($con,$sql);

while (
$row=mysqli_fetch_array($result)){
    echo 
'<div id="artist">';
    echo 
'<img src="'.$row['artist_image'].'">';
    echo 
'<section>';
    echo 
'<h2>'.htmlentities($row['artist_name']).'</h2>';
    
    
//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 
'<br>';
    
    echo 
'<a href="artist-detail.php?artist_id='.$row['artist_id'].'">more...</a><br>';
        
        
     echo 
'<a href="artist-update.php?artist_id='.$row['artist_id'].'"><img src="icons/update.png"></a>';  
     echo 
'<a href="artist-delete.php?artist_id='.$row['artist_id'].'"><img src="icons/delete.png"></a>';  
    
    echo 
'</section>';
    
     echo 
'</div>'.PHP_EOL;
}
?>

            <?php mysqli_close($con);  //Close Connection ?>

        </div>
        <div id="sub-nav">
            <a href="artist-create.php"><span>+</span><span>Artist</span></a>
        </div>
    </main>

</body>

</html>