= '".$weekdate[$i]."' AND cal_date <= '".$weekend[$i]."',cal_date,". " IF(alt_date_1 >= '".$weekdate[$i]."' AND alt_date_1 <= '".$weekend[$i]."',alt_date_1,". " IF(alt_date_2 >= '".$weekdate[$i]."' AND alt_date_2 <= '".$weekend[$i]."',alt_date_2,". " IF(alt_date_3 >= '".$weekdate[$i]."' AND alt_date_3 <= '".$weekend[$i]."',alt_date_3,". " IF(alt_date_4 >= '".$weekdate[$i]."' AND alt_date_4 <= '".$weekend[$i]."',alt_date_4,cal_date))))) AS sort_date ". " FROM green_calendar ". " WHERE (cal_date >= '".$weekdate[$i]."' AND cal_date <= '".$weekend[$i]."')". " OR (alt_date_1 >= '".$weekdate[$i]."' AND alt_date_1 <= '".$weekend[$i]."')". " OR (alt_date_2 >= '".$weekdate[$i]."' AND alt_date_2 <= '".$weekend[$i]."')". " OR (alt_date_3 >= '".$weekdate[$i]."' AND alt_date_3 <= '".$weekend[$i]."')". " OR (alt_date_4 >= '".$weekdate[$i]."' AND alt_date_4 <= '".$weekend[$i]."')". " ORDER BY IF(category='Featured Event',0,1), category ASC, sort_date ASC, start_time ASC, headline ASC"; $result=mysql_query($query) or die("Data is not currently available."); $r=0; $html[$i]=''; $curr_header=''; $category=''; while ($row=mysql_fetch_assoc($result)) //cycle through items for this date, add to array { $date_list=''; $temp_date=''; //show photo if there is one if($row['item_photo'])$html[$i].='

'; //show category when appropriate if (!$category || $row['category']!=$category) { $html[$i].='

'.$row['category'].'

'; $category = $row['category']; } //show headline if($row['headline'])$html[$i].='

'.$row['headline'].'
'; //get list of dates in current week for current event $temp_date=strtotime($row['cal_date']); if ($temp_date>=strtotime($weekdate[$i]) && $temp_date <= strtotime($weekend[$i])) $date_list.=date('F j, Y',$temp_date).'
'; $temp_date=strtotime($row['alt_date_1']); if ($temp_date>=strtotime($weekdate[$i]) && $temp_date <= strtotime($weekend[$i])) $date_list.=date('F j, Y',$temp_date).'
'; $temp_date=strtotime($row['alt_date_2']); if ($temp_date>=strtotime($weekdate[$i]) && $temp_date <= strtotime($weekend[$i])) $date_list.=date('F j, Y',$temp_date).'
'; $temp_date=strtotime($row['alt_date_3']); if ($temp_date>=strtotime($weekdate[$i]) && $temp_date <= strtotime($weekend[$i])) $date_list.=date('F j, Y',$temp_date).'
'; $temp_date=strtotime($row['alt_date_4']); if ($temp_date>=strtotime($weekdate[$i]) && $temp_date <= strtotime($weekend[$i])) $date_list.=date('F j, Y',$temp_date).'
'; //show date(s) - use alt text if present if ($row['text_date']) { $html[$i].=''.$row['text_date'].'
'; } else { $html[$i].=''.$date_list.''; } //show abstract $html[$i].=$row['item_abstract'].'
'; //show url link if($row['url'])$html[$i].='More...
'; //show location if($row['location'])$html[$i].=''.$row['location'].'
'; //show time $times=($row['start_time'] && $row['start_time']!='00:00:00'?date("g:i a", strtotime($row['start_time'])):'').($row['end_time'] && $row['end_time']!='00:00:00'?' to '.date("g:i a", strtotime($row['end_time'])):''); if($times)$html[$i].=''.$times.'
'; $html[$i].='

'; } if ($html[$i]=='') $html[$i]='

No events added yet.
View all events.

'; } mysql_free_result($result); $prevweek=date('Y-m-d',strtotime("$firstdayofweek -3 WEEKS")); //for links to previous and next set of days at top of calendar $nextweek=date('Y-m-d',strtotime("$firstdayofweek +3 WEEKS")); ?>