BraedenP
BraedenP

Reputation: 7215

Populating a Schedule Calendar

I'm creating a scheduling system for my school that allows teachers to book rooms/vehicles. I'm just stuck on one aspect: populating the calendar. Basically, it'll have a month and week view. The monthly view I'm fine coding, but it's the weekly view I'm stuck on.

The people that are inserting bookings will be able to specify the date of the booking, and the block(s) of the day that it takes up. I could recurse through the days/blocks in the week, running queries on those days and seeing if something is booked at that time, but that would be WAY too inefficient.

My second idea was to get a timestamp for the first and last days of the week and then populate an associative array with all of those dates. Then I could recurse through the blocks of all the days and find any matches in the array. That's a bit better, but it still seems to inefficient for me.

Is there a better way of doing this?

Upvotes: 0

Views: 2624

Answers (2)

santosh
santosh

Reputation: 132

You can use quick calendar, its very simple, you just need to pass SQL query to that, it will work as it is expected.

check this tutorial

http://www.evolt.org/quick_calendar_using_ajax_and_php

Upvotes: 1

Jonathan Patt
Jonathan Patt

Reputation: 1572

Select all the events which occur on dates on or between the start and end of the active week, put the results in an array, then loop through the days in the week and check whether events in the array take place on the active day.

Upvotes: 1

Related Questions