summaryrefslogtreecommitdiffstats
path: root/products.php
diff options
context:
space:
mode:
Diffstat (limited to 'products.php')
-rw-r--r--products.php45
1 files changed, 45 insertions, 0 deletions
diff --git a/products.php b/products.php
new file mode 100644
index 0000000..b8391d9
--- /dev/null
+++ b/products.php
@@ -0,0 +1,45 @@
+<?php
+if(isset($_GET['id']))
+{
+ $id = $_GET['id'];
+}
+else
+{
+ header('Location: categories.php');
+}
+require_once('vendor.inc.php');
+
+$category = CategoryQuery::create()->filterById($id)->findOne();
+$products = $category->getProducts();
+?>
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="UTF-8">
+<title>Products</title>
+<link rel="stylesheet" type="text/css" href="styles/style.css">
+</head>
+<body>
+<header><h1><?php echo $category->getName(); ?></h1></header>
+<nav>
+<dl>
+<dt><a href="contact.html">Contact us</a></dt>
+<dt><a href=".">Home</a></dt>
+<dt><a href="categories.php">Categories</a></dt>
+<dt><a href="login.html">Login</a></dt>
+</dl>
+</nav>
+<div id="content">
+<dl>
+<?php
+foreach( $products as $product ){
+ echo "<dt><a href=\"productdetails.php?id={$product->getId()}\">{$product->getName()}</a></dt>";
+ echo "<dd>{$product->getDescription()}</dd>";
+}
+?>
+</dl>
+<div class="spacer"></div>
+</div>
+<footer>Copyright by SomeCompany Ltd.</footer>
+</body>
+</html> \ No newline at end of file