Welcome Guest, Not a member yet? Register   Sign In
Outlook-esque "Week View" Calendar
#1

[eluser]derekmichaeljohnson[/eluser]
I'm attempting to create a week view calendar with 7 columns (days of the week) and 8 rows (work hours of the day 9am to 5pm). See this image for an example.

How can I best create a model that would not only populate an array with the hours in a work day (9am to 5pm) but also assign any events (from the db) to that hour, if any? Example:

Code:
array(
  '9am' => 'some event',
  '10am' => '',
  '11am' => 'some other event'
  // all the way to 5pm
);

Thanks in advance!
#2

[eluser]Jondolar[/eluser]
Hi derek,

I wrote a calendaring program many moons ago. My technique was to create an array of all the hours that I wanted to be covered in the calendar by default. Then, query the database for all events of the day and assign each event to the proper array subscript.

Code:
$cal = array(
  '9' => array(),
  '10' => array(),
  '11' => array()
  // all the way to 5pm
);

while ($row = mysql_fetch_assoc($result)){
    $cal[$row['starttime']][] = $row;
}

This allows for multiple events per time slot.




Theme © iAndrew 2016 - Forum software by © MyBB