Example #1
0
include_once "libs/php/utils.php";
include_once "config/database.php";
include_once "objects/product.php";
include_once "objects/product_image.php";
include_once "objects/category.php";
// initialize utility class
$utils = new Utils();
// get database connection
$database = new Database();
$db = $database->getConnection();
// initialize objects
$product = new Product($db);
$product_image = new ProductImage($db);
$category = new Category($db);
// ount all products
$products_count = $product->countAll();
// set page title
$page_title = "Products <small>{$products_count}</small>";
// include page header HTML
include_once 'layout_head.php';
// to prevent undefined index notice
$action = isset($_GET['action']) ? $_GET['action'] : "";
// used when somethign was added to cart
$id = isset($_GET['id']) ? $_GET['id'] : "";
$name = isset($_GET['name']) ? htmlspecialchars($_GET['name'], ENT_QUOTES, 'UTF-8') : "";
// if a product was added to cart
if ($action == 'added') {
    echo "<div class='alert alert-info'>";
    echo "<strong>{$name}</strong> was added to your cart!";
    echo "</div>";
} else {