-
Php time validation
I'm new to php and now i have a trouble on time. You see i must have a system in which you can reserve a time on a specific station. my problem is. what must i do so that no 2 times will conflict with the other time example?
SationNo.................TimeStart.........................TimeFinish
1.......................2:00..................................3:00
1.......................2:30..................................3:00
now the first one conflicts with the other. that must not happen since they have a conflict with time..
please help me.....
-
-
I would do something like this:
1...2:30...3:00 TAKEN
1...3:30...4:00 OPEN
1...4:30...5:00 TAKEN
1...5:30...6:00 OPEN
And have all the listings - then when someone signs up they can just change it to TAKEN from OPEN. (obviously using a file db, xml db, or mysql db)
-
-
Make a separate table for time and station in the database.. like, 1 table for the entity time, 1 table for the entity station.. And the relationship would be, a station can have 1 or more time ([7:00 - 8:00], [8:00-9:00], etc.), and the time belongs to 1 or more station (station1,station2,etc.).
table: TIME
attributes:
timeStart, timeFinish, timeId (primary key)
table: STATION
attibutes:
stationName, stationId (primary key)
table: STATION_TIME
attributes:
stationID, timeID, status (status whether it is taken or not)
It's up to you what attributes you include or make as a primary key.
In this case, you can just print all the times and stations (using html, php, etc.) where the status in the STATION_TIME table is OPEN ( OPEN here means, that time in a specific station is available). you can use the value OPEN as available and CLOSE if not available or AVAILABLE if available and TAKEN if not available, in the status, depending on your naming/value conventions. So, all available time will be printed on the browser which avoid conflicts in time. Don't forget to update the status in the STATION_TIME table whenever someone make reservations or someone finished his reservation.
-
The Following User Says Thank You to heavensgate15 For This Useful Post:
-
You can actually just skip "available" times because you can just know that any non-reserved time is available.
So follow everything above, but no need to deal with "reserved" or "available"-- just have a table called "station_reservations" and check if there is already a reservation for that time. If so, then it's reserved and not available. If not, it's available and can be reserved.
Daniel -
Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
-
The Following User Says Thank You to djr33 For This Useful Post:
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks