hoopplaya4 Posted February 27, 2009 Share Posted February 27, 2009 Hey All, I'm currently trying to create a PHP calendar. Everything is going great so far, but I am having issues figuring out the logic for events that "wrap" or overflow to the next week below (for events that are multiple days). The basic structure of the code is using <DIVS>, each consisting of a day. For example, <div id="day1">, <div id="day2">, etc... Then, the displayed events are <DIVS> within the day <DIV>. Here's the code showing the basic structure: (some parts have been removed to save space on this post): <?php $events = mysql_query("SELECT * FROM event WHERE month = '$month' AND year = '$year' ORDER BY starttime"); function isMultiDay($event) { return $event['day'] != null && ($event['dayend'] - $event['day'] >= 1); } while ( $event = mysql_fetch_array($events) ) { $event_type_id = $event['event_type_id']; $event_type = mysql_query("SELECT * FROM event_type WHERE id = '$event_type_id'"); $event_type = mysql_fetch_array($event_type); //SET UP Database Entries in MM/DD/YY Format $startDate = $event['month']."/".$event['day']."/".$event['year']; $endDate = $event['monthend']."/".$event['dayend']."/".$event['yearend']; if ( ($event['day'] == 1) && (!isMultiDay($event)) ) { $day[0] .= '<div id="event'.$event['id'].'" style="height:17px;"><div id=\'header'.$event['id'].'\'>'.$event['name'].'</div></div>';} if ( ($event['day'] == 1) && (isMultiDay($event)) ) { $day[0] .= '<div id="event'.$event['id'].'" style="height:17px;"><div id=\'header'.$event['id'].'\' style="width:'.$dayLength.'%;>'.$event['name'].'</div></div>';} if ( ($event['day'] == 2) && (!isMultiDay($event)) ) { $day[1] .= '<div id="event'.$event['id'].'" style="height:17px;"><div id=\'header'.$event['id'].'\'>'.$event['name'].'</div></div>';} if ( ($event['day'] == 2) && (isMultiDay($event)) ) { $day[1] .= '<div id="event'.$event['id'].'" style="height:17px;"><div id=\'header'.$event['id'].'\' style="width:'.$dayLength.'%;>'.$event['name'].'</div></div>';} if ( ($event['day'] == 3) && (!isMultiDay($event)) ) { $day[2] .= '<div id="event'.$event['id'].'" style="height:17px;"><div id=\'header'.$event['id'].'\'>'.$event['name'].'</div></div>';} if ( ($event['day'] == 3) && (isMultiDay($event)) ) { $day[2] .= '<div id="event'.$event['id'].'" style="height:17px;"><div id=\'header'.$event['id'].'\' style="width:'.$dayLength.'%;>'.$event['name'].'</div></div>';} //etc..... Any ideas on how to help with events overflowing to the next week? Maybe I'm doing this completely wrong, already? Thanks! Quote Link to comment Share on other sites More sharing options...
hoopplaya4 Posted March 2, 2009 Author Share Posted March 2, 2009 Any ideas? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.