开发者

PHP Multiple varying date and time booking data

I have a system for booking with lots of member sites that offer information to allow people to use our site to book with them.

With each member we need to know the dates, days of the week and times during those days they are available to book. This information does not change with number of bookings.

The problem is some members may allow bookings all year around between 9am and 6pm. Whilst others may have different booking times and days depending on the time of year and different days of the week at different times of the week.

Effectively what is needed is something like this:

<dateperiod>
   <weekday>
      <times>
         <price>
      <times>
   <weekday>
<dateperiod>

So one that is filled in might look like this.

<dateperiod>January,February,March
   <weekday>Mon,Tue,Wed,Thu,Fri
      <times>6-12
         <price>25<price>
      <times>开发者_Python百科
      <times>12-18
         <price>40<price>
      <times>
      <weekday>Sat,Sun
      <times>6-13
         <price>45<price>
      <times>
      <times>13-17
         <price>55<price>
      <times>
   <weekday>
<dateperiod>

Now that looks suspiciously like an XML feed. Not my intention but that is the kind of data structure that needs to be created in the admin panel for each member and extracted by the booking system on each page.

How the hell do we achieve something like this.

Any ideas?


Assuming you're using MySQL, the following structure should do it:

months set('January', 'February', ..., 'December') not null
weekdays set('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun') not null
hours_from tinyint(2) unsigned not null default 9 // could be other type if you need minutes, though
hours_to tinyint(2) unsigned not null default 18 // same as above
price decimal(3,2) not null

... and your WHERE statement would be something like this:

... WHERE '<input month>' IN(months)
          AND '<input day>' IN(weekdays)
          AND '<input hours>' BETWEEN hours_from AND hours_to
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜