dxm31 — 2011-12-15T18:10:39-05:00 — #1
I'm starting a new project for a company I work for not sure if they will end up using it or not. I am not a programmer but am working on learning it. I have been asked to make a php/sql schedule for the rink to display all the events for the day. So far I have my database set up with the following columns: date, event, event_title, start_time, end_time, team_one, team_one_lr, team_two, team_two_lr. All of the datatypes are set at varchar since I am not to familiar with all the other types.
The problem I am trying to solve atm is when adding events to the schedule how do I check to make sure the times do not conflict? Its not a huge issue but I would like a warning to pop up if someone try's to add a event that conflicts with something already in the DB.
Another issue I am trying to solve is when displaying the events for the day I want the event's that have all ready taken place to no longer be displayed. Ex. If a game ends at 10:00 at 10:10 I want the event to be taken off. I think I know how to get the page to refresh every time minutes using this
header("Refresh: 600; url='\\condition\\index.php'");
cheesedude — 2011-12-15T20:44:40-05:00 — #2
You would accomplish what you want using SQL queries, not in PHP.
There are different ways you could do what you want to do. For example, you could run a query to see if there is an existing reservation and if so, output a notice indicating a message indicating such.
If you want to make sure old events are not showing, you would run a query selecting the upcoming events for today where the time of the event is greater than the current time.
You should also put a unique ID field in your table, unless the event serves as the unique ID.
cups — 2011-12-16T08:49:31-05:00 — #3
When considering any kind of calendaring system you must appreciate that Mysql DATE and TIME fields offer far superior possibilities when you can see you will be querying for dates/times.