📁 File Manager
Editing:
/home/wedigitalindia/www/jaybalajiassociates.com/admin/view_product.php
<?php include("connection.php"); include("header.php"); ?> <div class="main-content"> <div class="page-content"> <div class="container-fluid"> <!-- start page title --> <div class="row"> <div class="col-12"> <div class="page-title-box d-sm-flex align-items-center justify-content-between"> <h4 class="mb-sm-0 font-size-18">View Products</h4> </div> </div> </div> <!-- end page title --> <div class="row"> <div class="col-lg-12"> <div class="card"> <div class="card-body"> <div class="row mb-2"> <div class="col-sm-6 mt-3"> <div class="search-box me-2 d-inline-block"> <div class="position-relative"> <input type="text" class="form-control" autocomplete="off" id="searchInput" onkeyup="searchTable()" placeholder="Search by product name, slug, category..."> <i class="bx bx-search-alt search-icon"></i> </div> </div> </div> <div class="col-sm-6 mt-3"> <div class="text-sm-end"> <a href="add_product.php"> <button type="button" class="btn btn-success btn-rounded waves-effect waves-light mb-2"> <i class="mdi mdi-plus me-1"></i> Add Product </button> </a> </div> </div> <!-- end col--> </div> <!-- end row --> <div class="table-responsive"> <table class="table align-middle table-nowrap table-hover dt-responsive nowrap w-100" id="product-table"> <thead class="table-light"> <tr> <th scope="col">S.No</th> <th scope="col">Category</th> <th scope="col">Image</th> <th scope="col">Product Name</th> <th scope="col">Slug</th> <th scope="col">Line Code</th> <th scope="col">Created At</th> <th scope="col" style="width: 200px">Action</th> </tr> </thead> <tbody> <?php // Join products with top_categories to show category name $query = "SELECT p.*, t.name AS category_name FROM products p LEFT JOIN top_categories t ON p.top_category_id = t.id ORDER BY p.id DESC"; $sql = mysqli_query($con, $query); $serial = 1; if ($sql && mysqli_num_rows($sql) > 0) { while ($row = mysqli_fetch_assoc($sql)) { ?> <tr> <td><?php echo $serial++; ?></td> <td><?php echo htmlspecialchars($row['category_name'] ?? ''); ?></td> <td> <?php if (!empty($row['product_main_image'])): ?> <img src="./assets/images/products/<?php echo htmlspecialchars($row['product_main_image']); ?>" alt="Product Image" class="img-fluid" style="height:80px;width:80px;object-fit:cover;"> <?php else: ?> <span class="badge bg-secondary">No Image</span> <?php endif; ?> </td> <td><?php echo htmlspecialchars($row['product_name']); ?></td> <td><?php echo htmlspecialchars($row['slug']); ?></td> <td><?php echo htmlspecialchars($row['product_line_code']); ?></td> <td><?php echo htmlspecialchars($row['created_at']); ?></td> <td> <a href="edit_product.php?id=<?php echo (int)$row['id']; ?>"> <button type="button" class="btn btn-primary btn-rounded waves-effect waves-light mb-2"> <i class="far fa-edit"></i> Edit </button> </a> <a onclick="return confirm('Are you sure you want to delete this product?')" href="delete_product.php?id=<?php echo (int)$row['id']; ?>"> <button type="button" class="btn btn-danger btn-rounded waves-effect waves-light mb-2"> <i class="fas fa-trash"></i> Delete </button> </a> </td> </tr> <?php } } else { echo '<tr><td colspan="9" class="text-center">No products found.</td></tr>'; } ?> </tbody> </table> <!-- end table --> </div> <!-- end table responsive --> </div> </div> </div> </div> </div> <!-- container-fluid --> </div> <!-- End Page-content --> <?php include("footer.php"); ?> </div> <script> // Simple search filter (works on product name, category, slug, etc.) function searchTable() { let input = document.getElementById("searchInput"); let filter = input.value.toLowerCase(); let table = document.getElementById("product-table"); let trs = table.getElementsByTagName("tr"); for (let i = 1; i < trs.length; i++) { let tds = trs[i].getElementsByTagName("td"); let show = false; // loop all columns except last (Action) for (let j = 0; j < tds.length - 1; j++) { if (tds[j].innerText.toLowerCase().indexOf(filter) > -1) { show = true; break; } } trs[i].style.display = show ? "" : "none"; } } </script>
Save
Cancel