:: **Zploit** v1.0 | Current Path: **/home/kreativepixelz/finartindia.com/admin/**
:: Editing File: products_old.php
<?php require_once 'db.php'; require_once 'session.php'; include"header.php"; // Initialize variables for success/error messages (e.g., after a delete action) $status = isset($_GET['status']) ? $_GET['status'] : ''; $message = isset($_GET['msg']) ? htmlspecialchars($_GET['msg']) : ''; $categories = []; // Array to hold the fetched data // 2. Fetch all data from the collectiongroups table $sql = "SELECT g.*, c.name AS collection_group_name FROM `groups` g LEFT JOIN `collectiongroups` c ON g.collectiongroups_id = c.id ORDER BY CASE WHEN g.collectiongroups_id = 6 THEN 0 ELSE 1 END, g.collectiongroups_id, g.sort_order;"; $stmt = mysqli_prepare($conn, $sql); if ($stmt) { mysqli_stmt_execute($stmt); $result = mysqli_stmt_get_result($stmt); // Check if any rows were returned if (mysqli_num_rows($result) > 0) { // Fetch all results into the $categories array while ($row = mysqli_fetch_assoc($result)) { $categories[] = $row; } } mysqli_stmt_close($stmt); } else { // Handle SQL preparation error (optional, but good practice) $status = 'danger'; $message = 'Database query preparation failed: ' . mysqli_error($conn); } // Close database connection mysqli_close($conn); ?> <!-- start page content wrapper--> <div class="page-content-wrapper"> <!-- start page content--> <div class="page-content"> <!--start breadcrumb--> <div class="page-breadcrumb d-none d-sm-flex align-items-center mb-3"> <div class="breadcrumb-title pe-3"> Products</div> <div class="ps-3"> <nav aria-label="breadcrumb"> <ol class="breadcrumb mb-0 p-0 align-items-center"> <li class="breadcrumb-item"><a href="dashboard.php"><ion-icon name="home-outline"></ion-icon></a> </li> <li class="breadcrumb-item active" aria-current="page">Products</li> </ol> </nav> </div> </div> <!--end breadcrumb--> <div class="card"> <div class="card-body"> <div class=""> <div class="row"> <div class="col-sm-9"> <h5 class="">Products Details</h5> </div> <div class="col-sm-3"> <a href="products_add.php" class="btn btn-primary" style="float: right;">Add Product</a> </div> </div> </div> <!-- Alert Message Display (for success/error) --> <?php if ($status === 'success'): ?> <div class="alert alert-success alert-dismissible fade show" role="alert"> <strong>Success!</strong> <?php echo $message; ?> <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button> </div> <?php elseif ($status === 'danger'): ?> <div class="alert alert-danger alert-dismissible fade show" role="alert"> <strong>Error!</strong> <?php echo $message; ?> <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button> </div> <?php endif; ?> <div class="table-responsive mt-3"> <table class="table align-middle" id="example"> <thead class="table-secondary"> <tr> <th>ID</th> <th>Category Name</th> <th>Image</th> <th>Name</th> <!--<th>Subheading</th>--> <th>Created At</th> <th>Actions</th> </tr> </thead> <tbody> <?php if (empty($categories)): ?> <tr> <td colspan="7" class="text-center">No Products found in the database.</td> </tr> <?php else: ?> <?php foreach ($categories as $cat): ?> <tr> <td><?php echo htmlspecialchars($cat['id']); ?></td> <td><?php echo htmlspecialchars($cat['collection_group_name']); ?></td> <td> <?php $image_path = !empty($cat['image']) ? htmlspecialchars($cat['image']) : 'assets/images/placeholder.jpg'; ?> <img src="../uploads/group/<?php echo $image_path; ?>" class="rounded-3" alt="Category Image" style="width: 50px; height: 50px; object-fit: cover;"> </td> <td><?php echo htmlspecialchars($cat['subheading']); ?></td> <td><?php echo date('Y-m-d', strtotime($cat['created_at'])); ?></td> <td> <div class="d-flex order-actions"> <a href="products_view.php?id=<?php echo $cat['id']; ?>" class="me-3" title="Edit"> <ion-icon name="create-outline"></ion-icon> </a> <!-- Link to Edit Page --> <a href="products_edit.php?id=<?php echo $cat['id']; ?>" class="me-3" title="Edit"> <ion-icon name="create-outline"></ion-icon> </a> <!-- Link to Delete Handler (You will need to create category-delete.php) --> <a href="products_delete.php?id=<?php echo $cat['id']; ?>" onclick="return confirm('Are you sure you want to delete this category?')" title="Delete" class="text-danger"> <ion-icon name="trash-outline"></ion-icon> </a> </div> </td> </tr> <?php endforeach; ?> <?php endif; ?> </tbody> </table> </div> </div> </div> <?php include"footer.php";?> <script src="assets/plugins/datatable/js/jquery.dataTables.min.js"></script> <script src="assets/plugins/datatable/js/dataTables.bootstrap5.min.js"></script> <script src="assets/js/table-datatable.js"></script>