:: **Zploit** v1.0 | Current Path: **/home/kreativepixelz/www/sukhadaworldapp/admin/**
:: Editing File: testimonials.php
<?php require_once 'db.php'; require_once 'session.php'; include "header.php"; // --- Fetch Message Status --- $status = $_GET['status'] ?? ''; $message = htmlspecialchars($_GET['msg'] ?? ''); // --- Fetch Testimonials Records --- $testimonials = []; $sql = "SELECT id, image, name, occupation, review_desc, created_at FROM testimonials ORDER BY id DESC"; $stmt = mysqli_prepare($conn, $sql); if ($stmt) { mysqli_stmt_execute($stmt); $result = mysqli_stmt_get_result($stmt); if ($result && mysqli_num_rows($result) > 0) { while ($row = mysqli_fetch_assoc($result)) { $testimonials[] = $row; } } mysqli_stmt_close($stmt); } else { $status = 'danger'; $message = 'Database query failed: ' . mysqli_error($conn); } mysqli_close($conn); ?> <!-- PAGE CONTENT --> <div class="page-content-wrapper"> <div class="page-content"> <!-- Breadcrumb --> <div class="page-breadcrumb d-none d-sm-flex align-items-center mb-3"> <div class="breadcrumb-title pe-3">Testimonials</div> <div class="ps-3"> <nav aria-label="breadcrumb"> <ol class="breadcrumb mb-0 p-0"> <li class="breadcrumb-item"><a href="dashboard.php"><ion-icon name="home-outline"></ion-icon></a></li> <li class="breadcrumb-item active">Testimonials</li> </ol> </nav> </div> </div> <div class="card"> <div class="card-body"> <!-- Header --> <div class="row mb-3"> <div class="col-sm-9"><h5 class="mb-0">Testimonials List</h5></div> <div class="col-sm-3 text-end"> <a href="testimonials_add.php" class="btn btn-primary">Add Testimonial</a> </div> </div> <!-- Status Alert --> <?php if ($status === 'success'): ?> <div class="alert alert-success alert-dismissible fade show"> <strong>Success:</strong> <?= $message ?> <button type="button" class="btn-close" data-bs-dismiss="alert"></button> </div> <?php elseif ($status === 'danger'): ?> <div class="alert alert-danger alert-dismissible fade show"> <strong>Error:</strong> <?= $message ?> <button type="button" class="btn-close" data-bs-dismiss="alert"></button> </div> <?php endif; ?> <!-- TABLE --> <div class="table-responsive mt-3"> <table class="table align-middle" id="example"> <thead class="table-secondary"> <tr> <th width="60">Sr No</th> <th>Image</th> <th>Name</th> <th>Occupation</th> <th>Review</th> <th>Created At</th> <th class="text-center">Actions</th> </tr> </thead> <tbody> <?php if (empty($testimonials)): ?> <tr> <td colspan="7" class="text-center">No testimonials found.</td> </tr> <?php else: ?> <?php $sr = 1; foreach ($testimonials as $t): ?> <tr> <td><?= $sr++ ?></td> <td> <?php $img = !empty($t['image']) ? "../uploads/testimonials/" . $t['image'] : "assets/images/placeholder.jpg"; ?> <img src="<?= $img ?>" class="rounded-3" style="width: 60px; height: 60px; object-fit: cover;"> </td> <td><?= htmlspecialchars($t['name']) ?></td> <td><?= htmlspecialchars($t['occupation'] ?? '-') ?></td> <td><?= substr(htmlspecialchars($t['review_desc']), 0, 60) ?>...</td> <td><?= htmlspecialchars($t['created_at']) ?></td> <td class="text-center"> <div class="d-flex justify-content-center gap-3"> <a href="testimonials_edit.php?id=<?= $t['id'] ?>" title="Edit"> <ion-icon name="create-outline"></ion-icon> </a> <a href="testimonials_delete.php?id=<?= $t['id'] ?>" onclick="return confirm('Are you sure you want to delete this testimonial?')" class="text-danger" title="Delete"> <ion-icon name="trash-outline"></ion-icon> </a> </div> </td> </tr> <?php endforeach; ?> <?php endif; ?> </tbody> </table> </div> </div> </div> <?php include "footer.php"; ?> <!-- DataTables --> <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>