query("SELECT c.*, (SELECT COUNT(*) FROM bookings WHERE customer_id=c.id) as total_bookings, (SELECT COALESCE(SUM(total_price),0) FROM bookings WHERE customer_id=c.id AND status NOT IN ('cancelled')) as total_spent FROM customers c ORDER BY c.id DESC")->fetch_all(MYSQLI_ASSOC); ?>
| ID | Name | Phone | Bookings | Total Spent | Joined | Status | |
|---|---|---|---|---|---|---|---|
| = $c['id'] ?> | = htmlspecialchars($c['name']) ?> | = $c['email'] ?> | = $c['phone'] ?> | = $c['total_bookings'] ?> | = formatPrice($c['total_spent']) ?> | = date('d M Y', strtotime($c['created_at'])) ?> | = $c['status']?'Active':'Inactive' ?> |