JavaScript Editor Ajax software     Free javascripts 



Main Page

14.
Now create
category.php
in your
seophp
folder. This script displays category details:
<?php
// load the catalog library
require_once ‘include/catalog.inc.php’;
// load the URL factory library
require_once ‘include/url_factory.inc.php’;
// load pager library
require_once ‘include/simple_pager.inc.php’;
// retrieve the category details
$category_id = $_GET[‘category_id’];
$categories = Categories::get($category_id);
$category = $categories[0];
$category_name = $category[‘name’];
// retrieve the page number; if none is provided, assume 1
$page = isset($_GET[‘page’]) ? $_GET[‘page’] : 1;
// redirect to the proper URL if necessary
$proper_url = make_category_url($category[‘name’], $category_id, $page);
fix_url($proper_url);
// retrieve the products in the category
$products = Products::get(0, $category_id);
// send a 404 if the category does not exist.
if (!$products) {
header(“HTTP/1.0 404 Not Found”);
exit();
}
?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html>
<head>
<title><?php echo $category_name ?> - Cookie Ogre’s Warehouse</title>
</head>
<body>
<h1>
<?php echo $category_name ?> -
<a href=”/“>Cookie Ogre’s Warehouse</a>
</h1>
Find these extraordinary products in our
<b><?php echo $category_name ?></b> category:
<?php
// load the URL factory
require_once ‘include/url_factory.inc.php’;
// display each product
echo “<ul>”;
275
Chapter 14: Case Study: Building an E-Commerce Store
c14.qxd:c14 10:46 275


JavaScript Editor Ajax software     Free javascripts