如何使用 PHP 和 MySQL 基于计划条目创建可用性脚本?
我正在尝试为客户开发一种工具,返回一周中给定日期和时间的所有可用用户。例如,用户将输入他们当前的每周时间表,数据库将存储该时间表。该表的每一行将包含用户名、星期几、不可用开始时间和不可用结束时间。如果客户端要输入一天、开始时间和结束时间,我希望脚本返回在该给定时间可用的所有用户。您对如何解决这个问题有什么想法吗?具体来说,我正在寻找存储和处理信息的最有效方法。任何帮助将不胜感激。以下是可能的表结构的示例:
UserName DayOfWeek StartTime EndTime //Times when unavailable
jdoe Mon 09:30:00 10:30:00
jdoe Mon 11:30:00 12:45:00
jdoe Tue 14:50:00 16:20:00
hsmith Wed 16:20:00 17:55:00
I am trying to develop a tool for a client that returns all available users for a given day and time of the week. For example, the user will enter their current weekly schedule, and the database will store that schedule. Each row of that table will contain the Username, Day of Week, Start Time of unavailability, and End Time of unavailability. If the client were to input a day, start time, and end time, I want the script to return all users who are available for that given time. Do you have any ideas how to approach this problem? Specifically, I'm looking for the most efficient way to store the information and process it. Any help would be greatly appreciated. Here's an example of a possible table structure:
UserName DayOfWeek StartTime EndTime //Times when unavailable
jdoe Mon 09:30:00 10:30:00
jdoe Mon 11:30:00 12:45:00
jdoe Tue 14:50:00 16:20:00
hsmith Wed 16:20:00 17:55:00
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将开始和结束时间存储为日期,例如
2011-01-01 09:00:00
然后为了可用性,您可以执行类似我没有尝试过的操作,并且需要进行一些标准化,但是应该是一个起点
Store the Start and End times as dates e.g.
2011-01-01 09:00:00
then for availability you could do something likeI've not tried this out and there is some normalisation to be done but should be a starting point