D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home3
/
encodto1
/
sg.encodersunlimited.com
/
sgadminpr
/
Filename :
show-testimonial.php
back
Copy
<?php require_once('config.php'); // Handle delete request if (isset($_GET['delete_id'])) { $delete_id = $_GET['delete_id']; // Delete image if it exists $fetch_img = mysqli_query($conn, "SELECT image FROM testimonials WHERE id = $delete_id"); if ($fetch_img && mysqli_num_rows($fetch_img) > 0) { $img_row = mysqli_fetch_assoc($fetch_img); if (!empty($img_row['image']) && file_exists($img_row['image'])) { unlink($img_row['image']); } } // Delete testimonial mysqli_query($conn, "DELETE FROM testimonials WHERE id = $delete_id"); header("Location: show-testimonial.php"); exit; } // Fetch testimonials $sql = "SELECT * FROM testimonials ORDER BY created_at DESC"; $result = mysqli_query($conn, $sql); ?> <!doctype html> <html lang="en"> <head> <title>Show Testimonials</title> <?php include('../style2.php'); ?> <style> body, .add__property--heading__title, .table, .table th, .table td { color: #f0f0f0; } .table th { background-color: #1e1e2f; text-align: center; } .table td { background-color: #2a2a3c; vertical-align: middle; text-align: center; } .dashboard__container { background-color: #1a1a2f; padding: 30px; border-radius: 12px; box-shadow: 0 0 12px rgba(0,0,0,0.2); } .btn-sm { padding: 5px 10px; font-size: 0.875rem; margin: 2px; } img.testimonial-img { width: 80px; height: 80px; border-radius: 10px; object-fit: cover; border: 2px solid #444; } .table th, .table td { border-color: #444; } .no-data { text-align: center; padding: 40px 0; color: #ccc; } </style> </head> <body> <div class="dashboard__page--wrapper"> <?php include('sidebar.php'); ?> <div class="page__body--wrapper" id="dashbody__page--body__wrapper"> <main class="main__content_wrapper"> <div class="dashboard__container"> <div class="add__property--heading mb-4"> <h2 class="add__property--heading__title">Testimonial List</h2> </div> <div class="add__property--box"> <?php if ($result && mysqli_num_rows($result) > 0): ?> <table class="table table-bordered"> <thead> <tr> <th>#</th> <th>Name</th> <th>Designation</th> <th>Description</th> <th>Image</th> <th>Created At</th> <th>Actions</th> </tr> </thead> <tbody> <?php while ($testimonial = mysqli_fetch_assoc($result)): ?> <tr> <td><?php echo $testimonial['id']; ?></td> <td><?php echo htmlspecialchars($testimonial['name']); ?></td> <td><?php echo htmlspecialchars($testimonial['designation']); ?></td> <td style="text-align: left;"><?php echo nl2br(htmlspecialchars($testimonial['description'])); ?></td> <td> <img src="<?php echo $testimonial['image']; ?>" alt="Image" class="testimonial-img"> </td> <td><?php echo $testimonial['created_at']; ?></td> <td> <a href="edit-testimonial.php?id=<?php echo $testimonial['id']; ?>" class="btn btn-warning btn-sm">Edit</a> <a href="show-testimonial.php?delete_id=<?php echo $testimonial['id']; ?>" class="btn btn-danger btn-sm" onclick="return confirm('Are you sure you want to delete this testimonial?');">Delete</a> </td> </tr> <?php endwhile; ?> </tbody> </table> <?php else: ?> <div class="no-data">No testimonials found.</div> <?php endif; ?> </div> </div> </main> </div> </div> <?php include 'footer.php'; ?> </body> </html>