 <?php
 require 'database.php';
 // Get category ID
 $category_id = $_GET['category_id']; 
if (!isset($category_id)) {
 $category_id = 1;
 }
 // Get name for current category 
$query = "SELECT * FROH artist
 WHERE artistID = $category_id";
 $category = $db->query($query);
 $category = $category->fetch();
 $category_name = $category['artistName'];
 // Get all artist 
$query = 'SELECT * FROM artist 
ORDER BY artistID';
 $artist = $db->query($query);
 // Get album for selected category 
$query = "SELECT * FROH album
 WHERE artistID = $category_id 
ORDER BY albumID";
 $album = $db->query($query);
 ?>
<!D0CTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns = "ht tp://www.w3.org/1999/xhtml">
 <!-- the head section -->
 <head>
 <title>Task 2</title>
 <link rel="stylesheet" type="text/css" href="main.css" /> 
</head>
 <!-- the body section -->
 <body>
 <div id="page">
 <div id="main">
 <hl>Product List</hl>
 <div id="sidebar">
 <!-- display a list of artist -->
 <h2>Categories</h2>
 <ul class="nav">
 <?php foreach ($artist as $category) : ?>
 <li>
 <a href="?category_id=<?php echo $category['artistID']; ?>"> 
<?php echo $category['artistName']; ?>
 </a>
 </li>
 <?php endforeach; ?>
 </ul>
 </div>
 <div id="content">
 <!-- display a table of album -->
 <h2><?php echo $category_name; ?></h2>
 <table>
 <tr>
 <th>Code</th>
 <th>Name</th>
 <th class="right">Price</th>
 </tr>
 <?php foreach ($album as $product) : ?>
 <tr>
 <td><?php echo $product ['albumCode'] ; ?></td>
 <td><?php echo $product ['albumName'] ; ?></td>
 <td class="right"><?php echo Sproduct ['listPrice'] ; ?></td> 
</tr>
 <?php endforeach; ?>
 </table>
 </div>
 </div><!-- end main -->
 <div id=" footer">
  <p>&copy; <?php echo date("Yn); ?> Task 2, assignment 4.</p> 
 </div>
 </div><!-- end page - ->
 </body>
 </html>