0

Hi guys,
I've put together a little app which users can use to book off days.

I have a button made which reads "Book of this day for every week of the year".

Basically what I want it to do is:

1. User clicks the check box [exists already]
2. Select the the date from the drop down(i.e: Monday)
3. write to database every monday for the year 2010.

So if I book off next Tuesday, for example, AND select the checkbox for "book for every tuesday for the rest of the year" - the database should populate with the users info for every REMAINING Tuesday for the rest of the year.

Any ideas/hints on how I can go about doing this?

Thanks.

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by diafol
0

Well, we could give you a start, but what's your data structure (DB tables/fields). How do you need this stored - in a single field, e.g.

repeating_booking
id (Primary Key)
user_id (Foreign Key)
repeat_day (0 - 6)
start_date (int or date)
end_date (int or date)

OR in single booking date - single record

bookings
id (Primary Key)
user_id (Foreign Key)
bookdate (int or date)

Once you sort out your data structure and how your system interacts with it, the rest will be simple. You will probably need to query for possible 'clashes' / duplicate bookings etc. Which structure will allow you to do this most effectively?

IF you can book one-off days in addition to "this day for the rest of the year", you'll need to either use the second table type or both tables (although this could get messy).

The second table will require some php to create dates that meet the requirements. You can then decide to either loop through these and add each date individually, or add them batch-wise. Look at the php date and time functions in the manual. It is also suggested that dates are stored as integers (timestamp) or at a push unix-format dates. Unix dates may be better for readability if you're starting out.

I'm loathe to supply any real code, but will help with anything you come back with.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.