query('SELECT id, name, email, plan, status FROM customers ORDER BY id');
$customers = $stmt->fetchAll();
} catch (PDOException $e) {
// For development, you might want to log this error or display a generic message
// For production, log the error and show a user-friendly message.
error_log('Database error: ' . $e->getMessage());
$customers = []; // Ensure $customers is an empty array on error
// Optionally, set an error message to display to the user
$errorMessage = 'Could not retrieve customer data. Please try again later.';
}
function getStatusBadgeClass($status) {
switch (strtolower($status)) {
case 'active':
return 'bg-success';
case 'suspended':
return 'bg-warning text-dark';
case 'deactivated':
return 'bg-danger';
default:
return 'bg-secondary';
}
}
?>