6 years ago (2015-07-27)  Algorithm language |   First to comment  74 
post score 0 times, average 0.0

Project Restatement:

PROBLEM : HOTEL RESERVATION A hotel chain operating in Miami wishes to offer room reservation services over the internet. They have three hotels in Miami: Lakewood, Bridgewood and Ridgewood. Each hotel has separate weekday and weekend (Saturday and Sunday) rates. There are special rates for rewards customer as a part of loyalty program. Each hotel has a rated assigned to it.

  1. Lakewood with a rating of 3 has weekday rates as 110$ for regular customer and 80$ for rewards customer. The weekend rates are 90$ for regular customer and 80$ for a rewards customer.
  2. Bridgewood with a rating of 4 has weekday rates as 160$ for regular customer and 110$ for rewards customer. The weekend rates are 60$ for regular customer and 50$ for a rewards customer.
  3. Ridgewood with a rating of 5 has weekday rates as 220$ for regular customer and 100$ for rewards customer. The weekend rates are 150$ for regular customer and 40$ for a rewards customer.

Write a program to help an online customer find the cheapest hotel. The input to the program will be a range of dates for a regular or rewards customer. The output should be the cheapest available hotel. In case of a tie, the hotel with highest rating should be returned.

Project ideas and features

Data facilitates maintenance

For a real-life project, the star rating and price of a hotel cannot be fixed. In order to better maintain the hotel and price information and facilitate the system's later revision, the extremely guest decides to use the database management data.In view of the requirements of this item, when the project was implemented, only the WEB interface of the customer querying the hotel information was written. For managers, the star rating, name, and price of the hotel may be modified in the database. This project is not implemented to benefit the administrator. Management interface.

Platform is easy to expand

Although the project uses PHP to implement functions, and the client's query operation is implemented on the WEB platform, the extremely guest specifically deploys a code to generate JSON data packages on the server, which is conducive to extending related functions to JAVA/C/C++ and other platforms.Note: Since no privacy information is involved, the HTTP value transmission method is tentatively set to GET. Of course, the principle of the post method is roughly the same.

Building a Interface Using the Bootstrap Front End Library

In order to realize the appearance of interface and interface as soon as possible, this project uses the open source WEB front end library: Bootstrap

Project file structure

PHP to achieve hotel query: WEB + SQL database + JSON-API    

Common code

Class hotelOrder: hotel booking arrangement class, constructor incoming start time, end time, customer type code

Web interface code:

Query home page index.php:


Query result page:


  • Demo URL: http://wangbaiyuan.cn/others/hotel_reservation/index.php
  • Demo screenshot:

PHP to achieve hotel query: WEB + SQL database + JSON-API PHP to achieve hotel query: WEB + SQL database + JSON-API

JSON output code that can be extended to other platforms


  • Output Example: [{"name":"Lakewood","price":720,"rating":"3"},{"name":"Ridgewood","price":780,"rating":"5" },{"name":"Bridgewood","price":870,"rating":"4"}]



This article has been printed on copyright and is protected by copyright laws. It must not be reproduced without permission.If you need to reprint, please contact the author or visit the copyright to obtain the authorization. If you feel that this article is useful to you, you can click the "Sponsoring Author" below to call the author!

Reprinted Note Source: Baiyuan's Blog>>https://wangbaiyuan.cn/en/php-hotel-query-web-sql-json-api-2.html

Post comment


No Comment


Forget password?