🤩 File Manager - Mr.X
PHP:
8.3.33
Server:
Apache
OS:
Linux 5.14.0-611.49.1.el9_7.x86_64
User:
websparkit
Navigate
Upload:
Upload
New File
New Folder
Editing:testimonials.php
<?php // admin/testimonials.php require_once '../includes/db.php'; require_once '../includes/functions.php'; $success = ''; $error = ''; // Handle delete action if (isset($_GET['action']) && $_GET['action'] === 'delete' && isset($_GET['id'])) { $id = filter_var($_GET['id'], FILTER_VALIDATE_INT); if ($id !== false) { try { $stmt = $pdo->prepare("DELETE FROM testimonials WHERE id = ?"); $stmt->execute([$id]); $success = 'Testimonial deleted successfully!'; } catch (PDOException $e) { $error = 'Failed to delete testimonial: ' . $e->getMessage(); } } else { $error = 'Invalid testimonial ID.'; } } // Fetch testimonials try { $stmt = $pdo->query("SELECT * FROM testimonials ORDER BY created_at DESC"); $testimonials = $stmt->fetchAll(); } catch (PDOException $e) { die("Database lookup error: " . $e->getMessage()); } include '../includes/admin_header.php'; ?> <!-- Action Bar --> <div class="row align-items-center mb-4"> <div class="col-sm-6"> <h4 class="mb-0 text-dark"><i class="fas fa-quote-left me-2 text-royal"></i>Manage Testimonials</h4> </div> <div class="col-sm-6 text-sm-end mt-3 mt-sm-0"> <a href="testimonial_edit.php" class="btn btn-royal"> <i class="fas fa-plus-circle me-1"></i> Add New Testimonial </a> </div> </div> <?php if (!empty($success)): ?> <div class="alert alert-success border-0 shadow-sm mb-4"><i class="fas fa-check-circle me-2"></i><?php echo $success; ?></div> <?php endif; ?> <?php if (!empty($error)): ?> <div class="alert alert-danger border-0 shadow-sm mb-4"><i class="fas fa-times-circle me-2"></i><?php echo $error; ?></div> <?php endif; ?> <div class="card premium-card"> <div class="card-header-royal"> <h5 class="mb-0"><i class="fas fa-list me-2"></i>Client Testimonials List</h5> <small class="text-white-50">These testimonials will be showcased on your website homepage in a rotating carousel.</small> </div> <div class="card-body p-0"> <div class="table-responsive"> <table class="table table-hover align-middle mb-0"> <thead class="table-light"> <tr> <th class="ps-4" style="width: 80px;">ID</th> <th>Client Name</th> <th>Designation</th> <th>Rating</th> <th>Comment</th> <th>Date Created</th> <th class="text-end pe-4" style="width: 150px;">Actions</th> </tr> </thead> <tbody> <?php if (count($testimonials) > 0): ?> <?php foreach ($testimonials as $t): ?> <tr> <td class="ps-4 fw-bold text-muted">#<?php echo htmlspecialchars($t['id']); ?></td> <td><strong><?php echo htmlspecialchars($t['client_name']); ?></strong></td> <td><span class="text-muted small"><?php echo htmlspecialchars($t['designation'] ?? 'Homeowner'); ?></span></td> <td> <div class="text-warning"> <?php for ($i = 1; $i <= 5; $i++): ?> <i class="<?php echo $i <= $t['rating'] ? 'fas' : 'far'; ?> fa-star"></i> <?php endfor; ?> </div> </td> <td> <div class="text-muted small text-truncate" style="max-width: 300px;" title="<?php echo htmlspecialchars($t['comment']); ?>"> <?php echo htmlspecialchars($t['comment']); ?> </div> </td> <td><span class="small"><?php echo date('M d, Y', strtotime($t['created_at'])); ?></span></td> <td class="text-end pe-4"> <a href="testimonial_edit.php?id=<?php echo $t['id']; ?>" class="btn btn-outline-primary btn-sm me-1" title="Edit"> <i class="fas fa-edit"></i> </a> <a href="testimonials.php?action=delete&id=<?php echo $t['id']; ?>" class="btn btn-outline-danger btn-sm" onclick="return confirm('Are you sure you want to delete this testimonial?');" title="Delete"> <i class="fas fa-trash-alt"></i> </a> </td> </tr> <?php endforeach; ?> <?php else: ?> <tr> <td colspan="7" class="text-center py-5"> <i class="fas fa-quote-left fa-3x text-muted mb-3 d-block"></i> <h5 class="text-muted">No testimonials found</h5> <p class="text-muted small mb-3">Add customer testimonials to display on the homepage slider.</p> <a href="testimonial_edit.php" class="btn btn-royal btn-sm"> <i class="fas fa-plus-circle me-1"></i> Add First Testimonial </a> </td> </tr> <?php endif; ?> </tbody> </table> </div> </div> </div> <?php include '../includes/admin_footer.php'; ?>
Save Changes
Cancel
Create New File
Create New Folder