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); ?>

Customers

Export CSV
IDNameEmailPhoneBookingsTotal SpentJoinedStatus
Active':'Inactive' ?>