Well the first thing you should consider is how do you need your data? If I recall you are writing a week of data at a time by time interval.
So you would have something like so already:
PHP Code:
// loop from starting hour to ending hour by time interval
// loop Sunday through Saturday
// Output time slots horizontally
So with that said, your array ideally should try and identify where it falls in the time slots or at least store its' data so it can be easily identified into a specific time slot.
There are several ways to organize your data, I'll outline one, and we'll see if others agree with it or think a different organization is better suited.
PHP Code:
$timeSlots = array('Sunday' => array(), 'Monday' => array(), 'Tuesday' => array() ...);
while($row = mysql_fetch_array($result))
{
$timeSlots[date('l', $row['slotTime'])][] = array('time' => date('H:i:s', $row['slotTime']), 'status' => $row['slotStatus']);
}
print_r($timeSlots);
// idea of output:
// array(
// 'Sunday' = array(
// [0] = array(
// ['time'] = 09:00:00
// ['status'] = ""
// ),
// [1] = array(
// ['time'] = 09:15:00
// ['status'] = ""
// ),
// [2] = array(
// ['time'] = 09:30:00
// ['status'] = ""
// )
// ),
// 'Monday' = array(
// [0] = array(
// ['time'] = 09:15:00
// ['status'] = ""
// ),
// [1] = array(
// ['time'] = 09:30:00
// ['status'] = ""
// ),
// [2] = array(
// ['time'] = 09:45:00
// ['status'] = ""
// )
// ),
// ....
// ....
// 'Saturday' = array(
// [0] = array(
// ['time'] = 09:15:00
// ['status'] = ""
// ),
// [1] = array(
// ['time'] = 09:30:00
// ['status'] = ""
// ),
// [2] = array(
// ['time'] = 09:45:00
// ['status'] = ""
// )
// )
// )
//
Then as you loop through the time intervals and the weekdays you can loop through the day's array of time slots and check that if ['time'] fits in the current interval.
Hope this helps and if you choose this route and need a more thorough code set, let me know. I'd be glad to help you and I think this will get you started in a good direction.
Bookmarks