Forum Moderators: coopster

Message Too Old, No Replies

Need help in logic for prayer calendar

Need help in logic for prayer calendar

         

drooh

10:03 am on Jul 31, 2007 (gmt 0)

10+ Year Member



I am going to be building a 24 hour prayer calendar where people can sign up for a chosen 1 hr time slot of their choice.

I am trying to decide what kind of logic to use in my approach.

Would I want to create all the tables and rows ahead of time as far out as I can, say 10+ years? That could be alot of work.

Is there a way to auto generate tables or rows as time goes on?

Does anyone have any suggestions to what may be the best approach?

Essentially there would be 24 slots per day that were available for sign up. Would this need to be ongoing or just a few months out at a time?

darrenG

2:30 pm on Jul 31, 2007 (gmt 0)

10+ Year Member



Each hour slot has an ID set to its exact date and time, along with the details of the person/entity that has booked that slot. If no-one has booked a particular slot, there is no entry in the database for that date/time. Only when someone books a slot is there a record created in the database.

Empty slots (hours of a given day that are not booked, and therefore not present in the DB) are handled using PHP, being available for booking etc...

Hope that helps..

Sagaris

3:58 pm on Jul 31, 2007 (gmt 0)

10+ Year Member



darrenG method of having one table that you add a row into for each booked slot is 100% the way I would go.

From your original post I think you may have been thinking about creating a table for every day/month. This (as you say) would be a nightmare to keep on top of, not to mention massively inefficient.

By using a single table to store the times and dates of booked slots you will save a lot of work in the long term. Always make the script/database do the hardwork! ;)

When you come to book a time, you would have to run a query on the bookings table to select all of the rows where the date the user wishes to book matches a date you have selected and then use some PHP to work out which times are free based on the times already booked for that day (retrived in your select query).

[edited by: Sagaris at 3:59 pm (utc) on July 31, 2007]

drooh

3:41 am on Aug 1, 2007 (gmt 0)

10+ Year Member



Ok, so it sounds like perhaps having a link appear inside each available slot that knows its id (date-time) and when you click it, it enters data to the db.

Now what about showing a month at a time or just todays date + 2 weeks? How would I set it up for them to look ahead, or should it be locked at only 2 weeks out?

Sagaris

12:47 pm on Aug 1, 2007 (gmt 0)

10+ Year Member



Deciding how far ahead you allow users to book a slot is really a decision for you and what suits your users the best. Are they likely to want to book ahead a long way in advance or just in the few days running up to a slot.

jatar_k

1:15 pm on Aug 1, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



you should be able to find the functionality in any calendar script around, might give a good starting point