简体   繁体   中英

Wordpress MySQL data retrieval Hotel booking reservation system

I am trying to create a Hotel reservation system using wordpress. Now, I know all the queries for data retrieval in a non-wordpress mode but I am facing some data-organization issues in dealing with wordpress. My hotels details are stored in the posts table and as custom fields for the hotel. For rates of the hotels, I created a different table according where rates vary according to months. I'd like the data to be displayed like this in my search results page:

Hotel_1 Name: (Will come from Post Name)
Hotel_1 Details: (Will come from custom fields)
Hotel_1 description: (will come from excerpt)
Room_1 Name for Hotel_1: Total Rates for selected dates 
Room_2 Name for Hotel_1: Total Rates for selected dates 
----------------------------------------------------------
Hotel_2 Name: (Will come from Post Name)
Hotel_2 Details: (Will come from custom fields)
Hotel_2 description: (will come from excerpt)
Room_1 Name for Hotel_2: Total Rates for selected dates 
Room_2 Name for Hotel_2: Total Rates for selected dates 
----------------------------------------------------------
and so on and so forth.....
----------------------------------------------------------
Pagination>> 

----------------------------------------------------------

My rates table looks like this

mysql> select * from rates;
+-------------+---------+---------+-------------------+------------+------------
+-----------+--------------+-----------+------------------------------------+
| primary_key | post_id | room_id | room_type            | start_date | end_date
| adultRate | extraBedRate | childRate | inclusions                         |
+-------------+---------+---------+-------------------+------------+------------
+-----------+--------------+-----------+------------------------------------+

where post_id = ID of the post in wp_posts table
room_id = ID given to a room
room_type = Name of the room

1 post (post_id) may have several room_types. Any help is much appreciated. Thanks.

I just need help on a. how to organize or create relationships among table to get desired result, & b. how to get them displayed in wordpress. Some classes or functions need to be considered.

I am very very new to php and mysql and this is my first assignment. My skill level is such that I can make changes to a code but right now it is very difficult for me to write from scratch. However with the help around here I intend to learn.

thanks

You're approaching this problem from the wrong point of view. There's a better way to handle this kind of information on WordPress and it doesn't (necessarily) involve creating new tables. WordPress handles CRUD natively so you will use pre-made functions instead of writing it from scratch.

Also, forget about using the original posts structure to do this, it can be a major headache. Instead, read everything you can about Custom Post Types and specially this awesome tutorial from Justin Tadlock

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM