34853-vm/admin/customers.php
2025-10-11 05:03:50 +00:00

48 lines
1.7 KiB
PHP

<?php
include __DIR__ . '/../db/config.php';
include 'header.php';
$pdo = db();
$stmt = $pdo->query('SELECT * FROM customers ORDER BY created_at DESC');
$customers = $stmt->fetchAll();
?>
<div class="d-flex justify-content-between align-items-center mb-4">
<h1>Customers</h1>
</div>
<table class="table table-striped table-bordered">
<thead class="table-dark">
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
<th>Address</th>
<th>Joined On</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php if (empty($customers)): ?>
<tr>
<td colspan="6" class="text-center">No customers found.</td>
</tr>
<?php else: ?>
<?php foreach ($customers as $customer): ?>
<tr>
<td><?php echo htmlspecialchars($customer['id']); ?></td>
<td><?php echo htmlspecialchars($customer['name']); ?></td>
<td><?php echo htmlspecialchars($customer['email']); ?></td>
<td><?php echo htmlspecialchars($customer['address']); ?></td>
<td><?php echo htmlspecialchars(date('Y-m-d', strtotime($customer['created_at']))); ?></td>
<td>
<a href="customer_edit.php?id=<?php echo $customer['id']; ?>" class="btn btn-sm btn-primary">Edit</a>
<a href="customer_delete.php?id=<?php echo $customer['id']; ?>" class="btn btn-sm btn-danger" onclick="return confirm('Are you sure?');">Delete</a>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
<?php include 'footer.php'; ?>