PHP/MySQL 时间表比较
我对我目前正在从事的一个项目有一个想法,但是我正在努力寻找一种在 PHP/MySQL 中实现它的方法。
我有一个数据库,其中包含纹身店的活动列表,基本上他从朝九晚五工作,当添加事件时,它会使用日期和时间添加到数据库中
| --- 日期----- |时间 |
2012-11-02 ---| 10:00:00
我想做的是列出下周纹身师时间表中尚未有活动进行的所有时间和日期,这也将确保纹身师也不会重复预订!
任何帮助都会有帮助,任何帮助都会有帮助
I have an idea for a project that I am currently working on, I am however struggling to find a way to implement this in PHP/MySQL.
I have a database with a list of activities that a tattoo parlour has, basically he works from 9 to 5 and when an event is added it is added to the database using date and time
| --- DATE----- | TIME |
2012-11-02 ---| 10:00:00
What I am trying to do is list all the times and dates within the tattooist timetable in the following week that does not already have events going on, this will also ensure the tattooist doesn't double book too!
any assistance will help guys, any assistance will help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
创建应用程序的最佳方法是将每个计划的事件存储到数据库中,并“取消”应用程序“事件”表已经占用的日期(按说法)...您可能需要进行事件创建检查在创建事件或将事件写入 mysql 数据库期间...您可能希望有一个事件表,其中包含每个事件的开始和结束时间...当您去安排事件时(假设用户输入决定事件时间和日期)只需编写一个选择事件的 mysql 查询其中 DATE(a.lastevent) = DATE(NOW())... 如果您还有其他问题,请告诉我
编辑:
我将使用 JavaScript 界面构建应用程序日历样式的前端。从长远来看,它将更加用户友好并且更容易创建,我已经在一天内实现了它们。
我建议使用的框架是ExtJS,有很多日历的教程和扩展,我知道ExtJS 3有日历内置于其中,您可以在此处查看相关教程:http://www.sencha.com/learn/using-calendar
另外,如果您决定使用 ExtJS4,则可以使用此插件:https://github.com/bmoeskau/Extensible/downloads 或这个 http://www.sencha.com /forum/showthread.php?142488-Extjs-4-based-open-source-Calendar-application
第二个链接是开源的,demo 看起来是西班牙语(它可以满足您的需要以及更多),但如果您使用 Chrome,您会得到顶部的一个栏询问您是否想要翻译该页面,单击“是”,它做得很好。从那里您可以进行查找和替换以将其转换为英语。
ExtJS 3 教程将向您展示如何将日历与 PHP 页面连接起来,以便您可以通过AJAX更新你的MySQL数据库。它比您想象的要简单得多,并且您可以从头开始编写代码,从而节省大量时间。
The best way to create the application is to store each scheduled event into a database and "black out" dates that are already taken by the applications "events" table (per say)... You will probably want to do your event creation checks during the point that the event would be created or written to the mysql db.... You will probably want to have an events table with a start and end time for each event.... when you go to schedule an event (assuming user input dictates event time and date) just write a mysql query that selects the event where the DATE(a.lastevent) = DATE(NOW())... let me know if you have further questions
Edit:
I would build the front end of the application calendar style using a JavaScript interface. In the long run it will be much more user friendly and much easier to create, I've implemented them in a day.
The framework I suggest using is ExtJS, there are many tutorials and extensions for calendars, I know that ExtJS 3 has a calendar built into it and you can view a tutorial on that here: http://www.sencha.com/learn/using-calendar
Additionally, if you decide to use ExtJS4, you can use this plugin: https://github.com/bmoeskau/Extensible/downloads or this one http://www.sencha.com/forum/showthread.php?142488-Extjs-4-based-open-source-Calendar-application
The second link is open source, the demo looks to be Spanish (it does what you need and more), but if you use Chrome you'll get a bar at the top asking if you want the page translated, click yes, it does a great job. From there you can do find and replaces to get it to English.
The ExtJS 3 tutorial will show you how to interface the calendar with a PHP page so that you can update your MySQL database via AJAX. It is much simpler than you might think, and you'll save a ton of time trying to code it from scratch.
有时这取决于每个预定活动的持续时间。您是仅使用时间戳添加这些事件,还是还跟踪分配的块的长度?
你可以使用开始和停止时间以及一些数学来设置约会。
我有一个恼人的倾向,即使用纪元时间戳而不是 mysql 日期时间。然后您可以进行计算以查看约会是否重叠或找到间隙。只需要学会以秒为单位计数或提供数学来调整:)。
Sometimes it depends on how long each scheduled event might be. Are you adding these events with just a timestamp or are you also tracking how long of a block is being assigned?
you could have an appointment set using a start and stop time and some math..
I have a annoying tendency to use a epoch timestamp instead of a mysql date time. then you can make calculations to see if an appointment overlaps or find the gaps. just have to learn to count in seconds or provide math to adjust :).