PHP Classes

File: fwphp/01mater/shop/catalog/index.php

Recommend this page to a friend!
  Classes of Slavko Srakocic  >  B12 PHP FW  >  fwphp/01mater/shop/catalog/index.php  >  Download  
File: fwphp/01mater/shop/catalog/index.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: B12 PHP FW
Manage database records with a PDO CRUD interface
Author: By
Last change: ver 7.0.5 mnu, msg, mkd FUNCTIONAL namespaces, CRUD PDO trait, pretty URL-s
Date: 2 months ago
Size: 1,107 bytes
 

Contents

Class file image Download
<?php
//see 2014_Murach's PHP and MySQL 2ndEd.pdf
//require_once('../util/m ain.php');
require_once('../model/product_db.php');
require_once(
'../model/category_db.php');

$category_id = filter_input(INPUT_GET, 'category_id', FILTER_VALIDATE_INT);
$product_id = filter_input(INPUT_GET, 'product_id', FILTER_VALIDATE_INT);
if (
$category_id !== null) { $action = 'category';}
elseif (
$product_id !== null) { $action = 'product'; }
else {
$action = ''; }

switch (
$action) {
    case
'category': // Display specified category
       
$category = get_category($category_id); // Get category data
       
$category_name = $category['categoryName'];
       
$products = get_products_by_category($category_id);
        include(
'./category_view.php'); // Display category
       
break;
    case
'product': // Display the specified product
       
$product = get_product($pp1); // $product_id Get product data
       
include('./product_view.php'); // Display product
       
break;
    default:
       
$error = 'Unknown catalog action: ' . $action;
        include(
'errors/error.php');
        break;
}
?>

For more information send a message to info at phpclasses dot org.