<?php //shows product data, allows going home, back to browsing or a product reload include 'CommonFunctions.php'; session_start(); $cat = filter_input(INPUT_GET, "cat"); $ref_page = filter_input(INPUT_GET, "ref_num"); $item_code = filter_input(INPUT_GET, "item"); $idx = filter_input(INPUT_GET, "idx"); if ($cat === null || $ref_page === null || $item_code === null || $idx === null) { header('Location: index.php'); } productsLoaded(); onlyCategory($cat); if ($GLOBALS['prod_array'][$idx][0] !== $item_code) { $item = findProd($item_code, $cat); } $item = $idx; $size = count($GLOBALS['prod_array']); ?> <html> <head> <meta charset="UTF-8"> <title> <?php echo $GLOBALS['prod_array'][$item][2]; ?> </title> </head> <body> <?php
function findProd($code, $category) { onlyCategory($category); $size = count($GLOBALS['prod_array']); for ($b = 0; $b < $size; $b++) { if ($GLOBALS['prod_array'][$b][0] == $code) { return $b; } } return false; }