sql and php files for database view