Update SQL queries for xy.php to reflect new database structure.