Server : Apache/2.4.18 (Ubuntu) System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64 User : oppastar ( 1041) PHP Version : 7.0.33-0ubuntu0.16.04.15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, Directory : /var/www/indolok.id/public_html/ |
Upload File : |
<?php include_once 'header.php'; // Include database connection require_once 'db_connection.php'; $type = isset($_GET['type']) ? trim($_GET['type']) : ''; // Debug: Check what we're looking for if (empty($type)) { die("No type parameter provided in URL"); } // Get main category data $stmt = $conn->prepare("SELECT * FROM categories WHERE status = '1' AND alias = ? LIMIT 1"); if (!$stmt) { die("Prepare failed: " . $conn->error); } $stmt->bind_param("s", $type); if (!$stmt->execute()) { die("Execute failed: " . $stmt->error); } $result = $stmt->get_result(); $category = $result->fetch_assoc(); if (!$category) { // Debug: Show what aliases exist $debug_stmt = $conn->prepare("SELECT alias, category FROM categories WHERE status = '1'"); $debug_stmt->execute(); $debug_result = $debug_stmt->get_result(); echo "Category not found for alias: '$type'<br>"; echo "Available aliases:<br>"; while($debug_row = $debug_result->fetch_assoc()) { echo "- " . $debug_row['alias'] . " (" . $debug_row['category'] . ")<br>"; } die(); } // Get subcategories for filtering $subcategories_sql = " SELECT * FROM categories WHERE status = '1' AND parent = ? ORDER BY priority ASC "; $stmt_sub = $conn->prepare($subcategories_sql); $stmt_sub->bind_param("i", $category['id_categories']); $stmt_sub->execute(); $subcategories = $stmt_sub->get_result(); // Get selected subcategory from URL parameter $selected_subcategory = isset($_GET['sub']) ? trim($_GET['sub']) : ''; // Get products related to this category (filtered by subcategory if selected) if (!empty($selected_subcategory)) { // Get products from specific subcategory $products_sql = " SELECT p.* FROM products p INNER JOIN category_product cp ON p.id_products = cp.id_product INNER JOIN categories c ON c.id_categories = cp.id_category WHERE p.product_status = '1' AND c.alias = ? AND c.parent = ? ORDER BY p.priority ASC "; $stmt2 = $conn->prepare($products_sql); $stmt2->bind_param("si", $selected_subcategory, $category['id_categories']); } else { // Get all products from main category and its subcategories $products_sql = " SELECT DISTINCT p.* FROM products p INNER JOIN category_product cp ON p.id_products = cp.id_product INNER JOIN categories c ON c.id_categories = cp.id_category WHERE p.product_status = '1' AND (c.id_categories = ? OR c.parent = ?) ORDER BY p.priority ASC "; $stmt2 = $conn->prepare($products_sql); $stmt2->bind_param("ii", $category['id_categories'], $category['id_categories']); } $stmt2->execute(); $products = $stmt2->get_result(); $conn->close(); ?> <section class="u-clearfix u-image u-section-1" id="sec-5169" data-image-width="1280" data-image-height="853" style="background-image: linear-gradient(0deg, rgba(0,0,0,0.5), rgba(0,0,0,0.5)), url('<?= $url ?>cms/uploads/category/<?= $category['image'] ?>'); background-position: 50% 50%;"> <div class="u-clearfix u-sheet u-valign-middle u-sheet-1" > <h1 class="u-align-center u-text u-text-body-alt-color u-title u-text-1" style="text-transform: uppercase; margin: 60px;"><?= $category['category'] ?></h1> </div> </section> <?php if (empty($selected_subcategory)): ?> <section class="u-clearfix u-white u-section-2" id="airport-security-solutions"> <div class="u-clearfix u-sheet u-valign-middle-lg u-valign-middle-md u-valign-middle-sm u-valign-middle-xl u-sheet-1" style="min-height: 500px;"> <div class="u-clearfix u-expanded-width u-layout-wrap u-layout-wrap-1"> <div class="u-layout"> <div class="u-layout-row"> <div class="u-container-style u-layout-cell u-size-30 u-layout-cell-1"> <div class="u-container-layout u-container-layout-1"> <img class="u-image u-image-default u-image-1" src="<?= $url ?>cms/uploads/category/<?= $category['thumbnail'] ?>" alt="<?= $category['category'] ?>" style="width:100%; object-fit: cover; height: 100%;"> </div> </div> <div class="u-align-left u-container-style u-layout-cell u-size-30 u-layout-cell-2" style="padding: 30px;"> <div class="normalFontSize u-container-layout u-container-layout-2"> <h2 class="u-custom-font u-text u-text-custom-color-5 u-text-1" style="font-family: Poppins; font-weight: 600;"><?= $category['category'] ?></h2> <?= $category['description'] ?> </div> </div> </div> </div> </div> </div> </section> <?php endif; ?> <section class="u-align-center u-clearfix u-container-align-center u-custom-color-10 u-section-3" id="sec-f608"> <div class="industryDetailBoxes u-clearfix u-sheet u-valign-middle u-sheet-1"> <h2 class="u-align-center u-custom-font u-text u-text-1" style="font-family: Poppins; font-size: 1.875rem; font-weight: 500; width: 100%; text-align:center; margin: 60px auto 0; color:#1d4c78 !important"> Produk <?= $category['category'] ?></h2> <!-- Subcategory Dropdown Filter --> <?php if ($subcategories && $subcategories->num_rows > 0): ?> <div class="subcategory-dropdown" style="margin: 30px 0 20px 0; text-align: center;"> <div style="display: inline-block; position: relative;"> <label for="categoryFilter" style="display: block; margin-bottom: 8px; color: #1d4c78; font-weight: 500; font-size: 0.9rem;">Filter by Category:</label> <select id="categoryFilter" onchange="filterCategory(this.value)" style="padding: 12px 40px 12px 16px; border: 2px solid #478ac9; border-radius: 8px; background: white; color: #1d4c78; font-size: 1rem; font-weight: 500; cursor: pointer; min-width: 250px; appearance: none; background-image: url('data:image/svg+xml;charset=US-ASCII,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4 5"><path fill="%23478ac9" d="M2 0L0 2h4zm0 5L0 3h4z"/></svg>'); background-repeat: no-repeat; background-position: right 12px center; background-size: 12px;"> <option value="" <?= empty($selected_subcategory) ? 'selected' : '' ?>>All Products</option> <?php // Reset subcategories result pointer $subcategories->data_seek(0); while($sub = $subcategories->fetch_assoc()): ?> <option value="<?= $sub['alias'] ?>" <?= $selected_subcategory === $sub['alias'] ? 'selected' : '' ?>> <?= $sub['category'] ?> </option> <?php endwhile; ?> </select> </div> </div> <script> function filterCategory(subcategory) { const currentUrl = new URL(window.location); if (subcategory) { currentUrl.searchParams.set('sub', subcategory); } else { currentUrl.searchParams.delete('sub'); } window.location.href = currentUrl.toString(); } </script> <?php endif; ?> <br> <div class="u-expanded-width u-layout-grid u-list u-list-1 productsSection"> <?php if (isset($products) && $products->num_rows > 0): ?> <div class="u-repeater u-repeater-1"> <?php while($row = $products->fetch_assoc()): ?> <div class="u-align-center u-container-style u-list-item u-repeater-item u-white"> <div class="u-container-layout u-similar-container u-valign-top"> <?php if (!empty($row['image1'])): ?> <a href="product-detail.php?slug=<?= $row['alias'] ?>"> <img class="u-image u-image-default" src="<?= $url ?>cms/uploads/product/<?= $row['image1'] ?>" alt="<?= $row['product'] ?>" style="width: 100%; object-fit: cover; margin-bottom: 15px;"> </a> <?php endif; ?> <h4 class="u-align-left u-custom-font u-text u-text-custom-color-5"> <a href="product-detail.php?slug=<?= $row['alias'] ?>"><?= $row['title'] ?></a> </h4> </div> </div> <?php endwhile; ?> </div> <?php else: ?> <p style="color:black; align-self:center">No products found in this category.</p> <?php endif; ?> </div> </div> </section> <?php include_once 'footer.php'; ?>