D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home3
/
encodto1
/
sg.encodersunlimited.com
/
Filename :
listing.php
back
Copy
<?php include 'sgadminpr/config.php'; // Initialize filters $category_id = isset($_GET['id']) ? intval($_GET['id']) : 0; $city_filter = isset($_GET['city']) ? $_GET['city'] : ''; $page = isset($_GET['page']) ? (int)$_GET['page'] : 1; if ($page < 1) $page = 1; // Build WHERE conditions $where = []; if ($category_id > 0) { $where[] = "p.id = $category_id"; } if (!empty($city_filter)) { $city_filter = $conn->real_escape_string($city_filter); $where[] = "p.city = '$city_filter'"; } $where_sql = !empty($where) ? 'WHERE ' . implode(' AND ', $where) : ''; // Get all unique cities for filter $cities_query = $conn->query("SELECT DISTINCT city FROM properties WHERE city IS NOT NULL AND city != '' ORDER BY city"); $cities = []; while ($row = $cities_query->fetch_assoc()) { $cities[] = $row['city']; } // Get all categories for filter $categories_query = $conn->query("SELECT id, category_name FROM categories ORDER BY category_name"); $categories = []; while ($row = $categories_query->fetch_assoc()) { $categories[$row['id']] = $row['category_name']; } // Pagination setup $itemsPerPage = 6; $offset = ($page - 1) * $itemsPerPage; // Get total count of filtered properties $totalQuery = "SELECT COUNT(*) AS total FROM properties p $where_sql"; $totalResult = $conn->query($totalQuery); $totalRow = $totalResult->fetch_assoc(); $totalItems = $totalRow['total']; $totalPages = ceil($totalItems / $itemsPerPage); // Fetch filtered properties with pagination $query = "SELECT p.*, c.category_name FROM properties p LEFT JOIN categories c ON p.id = c.id $where_sql ORDER BY p.created_at DESC LIMIT $itemsPerPage OFFSET $offset"; $result = $conn->query($query); ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Sgproperty partner - Listing Page</title> <?php include "style.php" ?> </head> <body> <!-- Start header area --> <?php include "header.php" ?> <!-- End header area --> <main class="main__content_wrapper"> <!-- Breadcrumb section --> <section class="breadcrumb__section section--padding"> <div class="container"> <div class="breadcrumb__content text-center" data-aos="fade-up" data-aos-duration="1200" data-aos-delay="100"> <h1 class="breadcrumb__title h2"><span>Listing</span> Page</h1> <ul class="breadcrumb__menu d-flex justify-content-center"> <li class="breadcrumb__menu--items"><a class="breadcrumb__menu--link" href="index.php">Home</a></li> <li><span><svg width="6" height="10" viewBox="0 0 6 10" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M5.22321 4.65179C5.28274 4.71131 5.3125 4.77976 5.3125 4.85714C5.3125 4.93452 5.28274 5.00298 5.22321 5.0625L1.0625 9.22321C1.00298 9.28274 0.934524 9.3125 0.857143 9.3125C0.779762 9.3125 0.71131 9.28274 0.651786 9.22321L0.205357 8.77679C0.145833 8.71726 0.116071 8.64881 0.116071 8.57143C0.116071 8.49405 0.145833 8.4256 0.205357 8.36607L3.71429 4.85714L0.205357 1.34821C0.145833 1.28869 0.116071 1.22024 0.116071 1.14286C0.116071 1.06548 0.145833 0.997023 0.205357 0.9375L0.651786 0.491071C0.71131 0.431547 0.779762 0.401785 0.857143 0.401785C0.934524 0.401785 1.00298 0.431547 1.0625 0.491071L5.22321 4.65179Z" fill="#706C6C" /> </svg> </span></li> <li><span class="breadcrumb__menu--text">Listing Page </span></li> </ul> </div> </div> </section> <!-- Breadcrumb section .\ --> <!-- Listing page section --> <section class="listing__page--section section--padding"> <div class="container"> <div class="row column-reverse-md"> <div class="col-lg-4"> <div class="listing__widget"> <div class="widget__search mb-30" data-aos="fade-up" data-aos-duration="1200" data-aos-delay="100"> <div class="widget__search--input position-relative"> <input class="widget__search--input__field" placeholder="Search product" type="text"> <button class="widget__search--btn"><svg width="16" height="17" viewBox="0 0 15 16" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M9.10714 9.54464C9.89286 8.75893 10.2857 7.81548 10.2857 6.71429C10.2857 5.61309 9.89286 4.67262 9.10714 3.89286C8.32738 3.10714 7.38691 2.71428 6.28571 2.71428C5.18452 2.71428 4.24107 3.10714 3.45536 3.89286C2.6756 4.67262 2.28571 5.61309 2.28571 6.71429C2.28571 7.81548 2.6756 8.75893 3.45536 9.54464C4.24107 10.3244 5.18452 10.7143 6.28571 10.7143C7.38691 10.7143 8.32738 10.3244 9.10714 9.54464ZM14.8571 14.1429C14.8571 14.4524 14.744 14.7202 14.5179 14.9464C14.2917 15.1726 14.0238 15.2857 13.7143 15.2857C13.3929 15.2857 13.125 15.1726 12.9107 14.9464L9.84822 11.8929C8.78274 12.631 7.59524 13 6.28571 13C5.43452 13 4.61905 12.8363 3.83929 12.5089C3.06548 12.1756 2.39583 11.7292 1.83036 11.1696C1.27083 10.6042 0.824405 9.93452 0.491071 9.16071C0.16369 8.38095 0 7.56548 0 6.71429C0 5.86309 0.16369 5.05059 0.491071 4.27678C0.824405 3.49702 1.27083 2.82738 1.83036 2.26786C2.39583 1.70238 3.06548 1.25595 3.83929 0.928571C4.61905 0.595237 5.43452 0.428571 6.28571 0.428571C7.13691 0.428571 7.94941 0.595237 8.72322 0.928571C9.50298 1.25595 10.1726 1.70238 10.7321 2.26786C11.2976 2.82738 11.744 3.78581 12.0714 4.06389C12.4048 5.05059 12.5714 5.86309 12.5714 6.71429C12.5714 8.02381 12.2024 9.21131 11.4643 10.2768L14.5268 13.3393C14.747 13.5595 14.8571 13.8274 14.8571 14.1429Z" fill="currentColor" /> </svg> </button> </div> </div> <div class="listing__widget--inner" data-aos="fade-up" data-aos-duration="1200" data-aos-delay="150"> <div class="widget__list mb-30"> <h2 class="widget__title mb-15">Product Categories</h2> <ul class="widget__catagories"> <li class="widget__catagories__list"> <label class="widget__catagories--label" for="check1"> <a href="listing.php<?= !empty($city_filter) ? '?city='.urlencode($city_filter) : '' ?>">All Categories</a> </label> </li> <?php foreach ($categories as $id => $name): ?> <li class="widget__catagories__list"> <label class="widget__catagories--label" for="check<?= $id ?>"> <a href="listing.php?id=<?= $id ?><?= !empty($city_filter) ? '&city='.urlencode($city_filter) : '' ?>"> <?= htmlspecialchars($name) ?> </a> </label> </li> <?php endforeach; ?> </ul> </div> <div class="widget__list mb-40"> <h2 class="widget__title mb-30">Find By Location</h2> <ul class="widget__location"> <li class="widget__location--list"> <label class="widget__location--label" for="check8"> <a href="listing.php<?= $category_id > 0 ? '?id='.$category_id : '' ?>">All Cities</a> </label> </li> <?php foreach ($cities as $city): ?> <li class="widget__location--list"> <label class="widget__location--label" for="check<?= md5($city) ?>"> <a href="listing.php?<?= $category_id > 0 ? 'id='.$category_id.'&' : '' ?>city=<?= urlencode($city) ?>"> <?= htmlspecialchars($city) ?> </a> </label> </li> <?php endforeach; ?> </ul> </div> </div> </div> </div> <div class="col-lg-8"> <div class="listing__page--wrapper"> <div class="listing__header d-flex justify-content-between align-items-center" data-aos="fade-up" data-aos-duration="1200" data-aos-delay="50"> <div class="listing__header--left"> <p class="results__cout--text">Showing <?= $result->num_rows ?> of <?= $totalItems ?> Results</p> </div> <div class="listing__header--right d-flex align-items-center"> <div class="recently__select d-flex align-items-center"> <span class="recently__select--icon"><svg width="14" height="13" viewBox="0 0 14 13" fill="none" xmlns="http://www.w3.org/2000/svg"> <path fill-rule="evenodd" clip-rule="evenodd" d="M7.42426 9.76048L10.1339 12.6088C10.3985 12.8869 10.8273 12.8869 11.0919 12.6088L13.8016 9.76048C14.0661 9.48239 14.0661 9.03159 13.8016 8.7535C13.537 8.47541 13.1082 8.47541 12.8436 8.7535L11.2903 10.3862V0.712076C11.2903 0.318811 10.987 0 10.6129 0C10.2388 0 9.9355 0.318811 9.9355 0.712076V10.3862L8.38222 8.7535C8.11766 8.47541 7.68881 8.47541 7.42426 8.7535C7.1597 9.03159 7.1597 9.48239 7.42426 9.76048ZM3.86611 0.208562C3.60156 -0.0695178 3.17264 -0.0695178 2.90809 0.208562L0.19841 3.05687C-0.0661366 3.33495 -0.0661366 3.78581 0.19841 4.06389C0.462956 4.34197 0.891881 4.34197 1.15643 4.06389L2.70968 2.43118V12.1053C2.70968 12.4985 3.01297 12.8174 3.3871 12.8174C3.76123 12.8174 4.06452 12.4985 4.06452 12.1053V2.43118L5.6178 4.06389C5.88236 4.34197 6.31121 4.34197 6.57576 4.06389C6.84032 3.78581 6.84032 3.33495 6.57576 3.05687L3.86611 0.208562Z" fill="currentColor" /> </svg> </span> <div class="select"> <select> <option selected value="1">Recently Added</option> <option value="2">Newest</option> <option value="3">Best Seller</option> <option value="4">Best Match</option> <option value="5">Price Low</option> <option value="6">Price High</option> </select> </div> </div> </div> </div> <div class="listing__main--content"> <div class="tab-content"> <div class="tab-pane fade show active" id="grid"> <div class="listing__featured--grid"> <div class="row mb--n30"> <?php if ($result->num_rows > 0): ?> <?php while ($row = $result->fetch_assoc()): // Fetch first image $imageQuery = "SELECT image_path FROM property_images WHERE property_id = ? LIMIT 1"; $imageStmt = $conn->prepare($imageQuery); $imageStmt->bind_param("i", $row['id']); $imageStmt->execute(); $imageResult = $imageStmt->get_result(); $imagePath = ($imageResult->num_rows > 0) ? 'sgadminpr/' . $imageResult->fetch_assoc()['image_path'] : 'sgadminpr/default.jpg'; $imageStmt->close(); $description = strlen($row['description']) > 50 ? substr($row['description'], 0, 50) . '...' : $row['description']; ?> <div class="col-lg-6 col-md-6 col-sm-6 mb-30" data-aos="fade-up" data-aos-duration="1200" data-aos-delay="50"> <article class="featured__card"> <div class="featured__thumbnail position-relative"> <div class="media"> <a class="featured__thumbnail--link" href="listing-details.php?id=<?= $row['id'] ?>"> <img class="featured__thumbnail--img" src="<?= htmlspecialchars($imagePath) ?>" alt="featured-img" style="object-fit: cover; width: 100%; height: 200px;"> </a> </div> </div> <div class="featured__content"> <div class="featured__content--top d-flex align-items-center justify-content-between"> <h3 class="featured__card--title"> <a href="listing-details.php?id=<?= $row['id'] ?>"><?= htmlspecialchars($row['title']) ?></a> </h3> </div> <p class="featured__content--desc"><?= htmlspecialchars($description) ?></p> <ul class="featured__info d-flex"> <li class="featured__info--items"> <span class="featured__info--icon"><?= ucfirst($row['status']) ?></span> <span class="featured__info--text">Status</span> </li> <li class="featured__info--items"> <span class="featured__info--icon"><?= htmlspecialchars($row['area']) ?> Sq.ft</span> <span class="featured__info--text">Area</span> </li> <li class="featured__info--items"> <span class="featured__info--icon">₹<?= number_format($row['price']) ?></span> <span class="featured__info--text">Price</span> </li> </ul> </div> </article> </div> <?php endwhile; ?> <?php else: ?> <div class="col-12"> <p class="text-center">No available properties found matching your criteria.</p> </div> <?php endif; ?> </div> </div> </div> </div> <?php if ($totalPages > 1): ?> <div class="page__pagination--area"> <ul class="page__pagination--wrapper d-flex justify-content-center"> <?php if ($page > 1): ?> <li class="page__pagination--list"> <a class="page__pagination--link" href="?<?= $category_id > 0 ? 'id='.$category_id.'&' : '' ?><?= !empty($city_filter) ? 'city='.urlencode($city_filter).'&' : '' ?>page=<?= $page - 1 ?>">‹</a> </li> <?php endif; ?> <?php for ($i = 1; $i <= $totalPages; $i++): ?> <li class="page__pagination--list"> <a class="page__pagination--link <?= $i === $page ? 'active' : '' ?>" href="?<?= $category_id > 0 ? 'category_id='.$category_id.'&' : '' ?><?= !empty($city_filter) ? 'city='.urlencode($city_filter).'&' : '' ?>page=<?= $i ?>"><?= $i ?></a> </li> <?php endfor; ?> <?php if ($page < $totalPages): ?> <li class="page__pagination--list"> <a class="page__pagination--link" href="?<?= $category_id > 0 ? 'id='.$category_id.'&' : '' ?><?= !empty($city_filter) ? 'city='.urlencode($city_filter).'&' : '' ?>page=<?= $page + 1 ?>">›</a> </li> <?php endif; ?> </ul> </div> <?php endif; ?> </div> </div> </div> </div> </div> </section> <!-- Listing page section . --> <?php include "footer.php" ?> </main> </body> </html>