/
var
/
www
/
html
/
stengineers
/
Upload FileeE
HOME
<?php header('Access-Control-Allow-Origin: *'); require_once 'admin/dbconnection.php'; error_reporting(0); // Sanitize input $categoryurl = isset($_GET['categoryurl']) ? trim($_GET['categoryurl']) : ''; // Fetch category $query = $con->prepare("SELECT * FROM category WHERE url = ?"); $query->bind_param("s", $categoryurl); $query->execute(); $result = $query->get_result(); $row2 = $result->fetch_assoc(); if (!$row2) { echo "Category not found"; exit; } $id = $row2['id']; $category_name = $row2['category_name']; $description = $row2['description']; $thumb_img = $row2['thumb_img']; $catgory_type = $row2['category_type']; $parent_categoryid = $row2['Parent_categoryid']; $meta_title = $row2['meta_title']; $metadescription = $row2['meta_description']; $h1_title = $row2['h1_title']; $status = $row2['status']; // Fetch parent category $query2 = $con->prepare("SELECT * FROM category WHERE id = ?"); $query2->bind_param("i", $parent_categoryid); $query2->execute(); $result2 = $query2->get_result(); $row2_c = $result2->fetch_assoc(); $mcategory_name = $row2_c['category_name'] ?? ''; $murl = $row2_c['url'] ?? ''; $pagetitle = ($meta_title != "") ? $meta_title : "ST Engineers | $category_name"; $h1tag = ($h1_title != "") ? $h1_title : $category_name; require 'header.php'; ?> <input type="hidden" id="scategid" value="<?php echo htmlspecialchars($id); ?>"> <!-- Start Page Header --> <section class="product-banner"> <div class="d-flex flex-column align-items-center"> <div class="page-header__inner text-center"> <h1><?php echo ucwords(htmlspecialchars($h1tag)); ?></h1> </div> </div> </section> <!-- Breadcrumbs --> <ol class="breadcrumb"> <li><a href="<?php echo $baseUrl; ?>products.php">Products</a></li> <li><a href="<?php echo $baseUrl; ?>category/<?php echo htmlspecialchars($murl); ?>"><?php echo ucwords(htmlspecialchars($mcategory_name)); ?></a></li> <li class="current"><?php echo htmlspecialchars($category_name); ?></li> </ol> <!-- Brand Filter Buttons --> <div class="logo-tab"> <?php $brandQuery = $con->query("SELECT DISTINCT b.id, b.brandlogo, b.brandname FROM brand AS b INNER JOIN products AS p ON b.id = p.brandid WHERE p.sub_category = '$id'"); while ($row = $brandQuery->fetch_assoc()) { $brandId = $row['id']; $brandlogo = $row['brandlogo']; $brandname = $row['brandname']; $check = $con->query("SELECT 1 FROM products WHERE brandid='$brandId' AND status='active' LIMIT 1"); if ($check->num_rows > 0) { echo "<button class='tab-btn' id='$brandId' onclick='brandFilter($brandId)'><img src='" . htmlspecialchars($brandlogo) . "'></button>"; } } echo "<button class='active tab-btn' id='all' onclick='brandFilter(\"all\")'>View All</button>"; ?> </div> <!-- Product Grid --> <div class="spacer"></div> <section class="vertical-sec"> <div class="container-fluid" id='parent'> <div class="row col-lg-10 mx-auto position-relative" id="brandfilter_data"> <?php $categoryQuery = $con->query("SELECT * FROM category WHERE id = '$id' AND status='active' ORDER BY category_name DESC"); while ($catRow = $categoryQuery->fetch_assoc()) { $categoryId = $catRow['id']; $productQuery = $con->query("SELECT * FROM products WHERE sub_category='$categoryId' AND status='active' ORDER BY display_order ASC"); while ($productRow = $productQuery->fetch_assoc()) { $productName = $productRow['product_title']; $machineImg = $productRow['preview_image']; $brandproID = $productRow['brandid']; $slug = $productRow['slug']; echo "<div class='col-xl-3 col-lg-6 col-md-6 new-box $brandproID'> <a href='" . $baseUrl . "product/$slug'> <div class='vertical-box'> <img src='" . $imageUrl . "product/green-bg.png' class='green-bg'> <img src='" . htmlspecialchars($machineImg) . "' class='position-relative w-90 img-shadow'> <h6>" . htmlspecialchars($productName) . "</h6> </div> </a> </div>"; } } ?> </div> </div> </section> <?php require 'footer.php'; ?> <!-- Brand Filter Script --> <script> $(document).ready(function() { $('.tab-btn').click(function() { const id = this.id; $('.tab-btn').removeClass('active'); $(this).addClass('active'); if (id === 'all') { $('.new-box').fadeIn(450); } else { $('.new-box').hide(); $('.' + id).fadeIn(450); } }); }); function brandFilter(id) { const scategid = $("#scategid").val(); $.ajax({ url: '../admin/api/admin-product.php', type: 'POST', data: { id: id, scategid: scategid, referer: "ezioaws", action: "brandfilter" }, success: function (data) { if (data !== "") { $('#brandfilter_data').html(data); } else { $('#brandfilter_data').html("<div style='color: red; text-align: center;'>No Products found for the brand</div>"); } }, error: function (xhr, status, error) { console.error("AJAX Error:", status, error); } }); } </script>