function get_products_search($s) { $results = array(); $all = get_products_all(); foreach ($all as $product) { if (stripos($product["english"], $s) !== false) { $results[] = $product; } } return $results; }
function get_products_search($search_term) { $results = array(); $all_products = get_products_all(); foreach ($all_products as $product) { if (stripos($product["name"], $search_term) !== false) { $results[] = $product; } } return $results; }
function get_products_subset($positionStart, $positionEnd) { $subset = array(); $all = get_products_all(); $position = 0; foreach ($all as $product) { $position += 1; if ($position >= $positionStart && $position <= $positionEnd) { $subset[] = $product; } } return $subset; }
function get_products_search($s) { //$s is search term $results = array(); $all = get_products_all(); //all is all rows of all products foreach ($all as $product) { if (stripos($product["name"], $s) == true) { $results[] = $product; } } return $results; }
<?php //Include product array data require_once "../inc/config.php"; require_once ROOT_PATH . 'inc/model/products.php'; $products = get_products_all(); /*Two things happening here: 1) If the incoming $_GET variable is is set, it is assigned to the working variable $product_id. 2) If the $products array element at index $product_id exists, then the individual T-shirt information (in array form) at that index is assigned to $product, the working T-shirt array for this page.*/ if (isset($_GET["id"])) { $product_id = $_GET["id"]; if (isset($products[$product_id])) { $product = $products[$product_id]; } } /*If either one of the above conditions fails (i.e. the working T-shirt array for this page is empty), redirect back to shirts.php.*/ if (!isset($product)) { header("Location: " . BASE_URL . "shirts/"); exit; } $section = "shirts"; $pageTitle = $product["name"]; include ROOT_PATH . "inc/view/header.php"; ?>
<?php include "inc/technologies-data.php"; if (isset($_GET["id"])) { $technology_id = $_GET["id"]; if (isset(get_products_all()[$technology_id])) { $technology = get_products_all()[$technology_id]; } } if (!isset($technology)) { header("Location: technologies.php"); exit; } $section = "shirts"; $pageTitle = $technology["name"]; include "inc/header.php"; ?> <div class="section page"> <div class="wrapper"> <div class="breadcrumb"><a href="index.php">Home</a> > <a href="technologies.php">Technologies</a> > <?php echo $technology["id#"]; ?> </div> <div class="shirt-details"> <div class="group"> <h1 id="ip-title"><?php echo $technology["name"];
<h2>Hey, I’m Huy!</h2> <p>Check Out My Shirts</p> </a> </div> </div> </div> <!-- Show latest shirts --> <div class="section shirts latest"> <div class="wrapper"> <h2 style="padding:20px;">RIT’ Latest Shirts</h2> <?php include "inc/products.php"; ?> <ul class="products"> <!-- Loop through each shirt and display the last four shirts. --> <?php $current = 0; $list_view_html = ""; foreach (get_products_all() as $product_id => $product) { $current += 1; if ($current > 16) { $list_view_html = get_list_view_html($product_id, $product) . $list_view_html; } } echo $list_view_html; ?> </ul> </div> </div> <?php include "inc/footer.php";
function get_products_recent() { $all = get_products_all(); $total_products = count($all); $position = 0; $list_view_html = ""; foreach ($all as $product) { $position = $position + 1; if ($total_products - $position < 4) { $list_view_html = get_list_view_html($product) . $list_view_html; } } return $list_view_html; }
// What page are we currently on? $page = min($pages, filter_input(INPUT_GET, 'page', FILTER_VALIDATE_INT, array('options' => array('default' => 1, 'min_range' => 1)))); // Calculate the offset for the query $offset = ($page - 1) * $limit; // Some information to display to the user $start = $offset + 1; $end = min($offset + $limit, $total); // Prepare the paged query // The "back" link $prevlink = $page > 1 ? '<a href="?page=1" title="First page">«</a> <a href="?page=' . ($page - 1) . '" title="Previous page">‹</a>' : '<span class="disabled">«</span> <span class="disabled">‹</span>'; // The "forward" link $nextlink = $page < $pages ? '<a href="?page=' . ($page + 1) . '" title="Next page">›</a> <a href="?page=' . $pages . '" title="Last page">»</a>' : '<span class="disabled">›</span> <span class="disabled">»</span>'; // Display the paging information echo '<div id="paging"><p>', $prevlink, ' Page ', $page, ' of ', $pages, ' pages, displaying ', $start, '-', $end, ' of ', $total, ' results ', $nextlink, ' </p></div>'; // Display the results $alldata = get_products_all(); for ($i = $start; $i <= $end; $i++) { $key = 100 + $i; echo get_list_view_html($key, $alldata[$key]); } // The "back" link $prevlink = $page > 1 ? '<a href="?page=1" title="First page">«</a> <a href="?page=' . ($page - 1) . '" title="Previous page">‹</a>' : '<span class="disabled">«</span> <span class="disabled">‹</span>'; // The "forward" link $nextlink = $page < $pages ? '<a href="?page=' . ($page + 1) . '" title="Next page">›</a> <a href="?page=' . $pages . '" title="Last page">»</a>' : '<span class="disabled">›</span> <span class="disabled">»</span>'; // Display the paging information echo '<div id="paging"><p>', $prevlink, ' Page ', $page, ' of ', $pages, ' pages, displaying ', $start, '-', $end, ' of ', $total, ' results ', $nextlink, ' </p></div>'; ?> <?php } ?>
include 'includes/header.php'; ?> <div class = "section shop page"> <div class = "wrapper2"> <h3>Mixed Media Art For Sale</h3> <div class = "shop"> <h1>Shop Here!</h1> <ul class = "products"> <?php $products = get_products_all($db); ?> <?php foreach ($products as $product) { echo "<li>"; echo '<a href="shopdetails.php?id=' . $product["sku"] . '">'; echo '<img src=" ' . $product["img"] . '" alt="' . $product["name"] . '">'; echo "<p>View Details</p>"; echo "</a>"; echo "</li>"; } ?> </ul> </div> </div>