[英]Wordpress MySQL data retrieval Hotel booking reservation system
I am trying to create a Hotel reservation system using wordpress. 我正在尝试使用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.
现在,我知道所有在非wordpress模式下进行数据检索的查询,但是在处理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. 1个帖子(post_id)可能有几种room_type。 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.
如何在表之间组织或创建关系以获得期望的结果; b。 how to get them displayed in wordpress.
如何使它们显示在WordPress中。 Some classes or functions need to be considered.
需要考虑一些类或功能。
I am very very new to php and mysql and this is my first assignment. 我对php和mysql非常陌生,这是我的第一份作业。 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上处理此类信息,并且(不必)涉及创建新表。 WordPress handles CRUD natively so you will use pre-made functions instead of writing it from scratch.
WordPress本机处理CRUD,因此您将使用预制函数,而不是从头开始编写它。
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
相反,请阅读有关定制帖子类型的所有内容,特别是贾斯汀·塔德洛克(Justin Tadlock)的这篇很棒的教程
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.