Changes database qureys in PHP

Made changes for the new database.