0, 'Monday' => 1, 'Tuesday' => 2, 'Wednesday' => 3, 'Thursday' => 4, 'Friday' => 5, 'Saturday' => 6 ); $GLOBALS['dayshorts'] = array( 'Sunday' => 'Sun', 'Monday' => 'Mon', 'Tuesday' => 'Tue', 'Wednesday' => 'Wed', 'Thursday' => 'Thu', 'Friday' => 'Fri', 'Saturday' => 'Sat' ); function emit_whatson($semester, $fromnow=0) { $if = "if"; $file = << EOT; // Nope. First, gather the schedule, THEN loop through it, so we can // stagger it if we need to. $query = "SELECT H.showname, D.DJName, H.url, H.startday, H.starttime, H.stoptime, SEC_TO_TIME(TIME_TO_SEC(H.stoptime)-60) AS other_stoptime FROM schedule H, DJ D WHERE semester='{$semester}' AND H.djid=D.DJID ORDER BY H.startday, H.starttime"; $res = mysql_query($query) or die(mysql_error()." -- ".$query); $schedule = array(); while( $row = mysql_fetch_array($res, MYSQL_ASSOC) ) { $schedule[] = $row; } // while thar be rows for( $i=0; $i 12 ) { $human_hour -= 12; } else { $ampm = 'am'; } $human_start = "{$human_hour}:{$starttime_arr[1]}"; $human_hour = ltrim($stoptime_arr[0], "0"); $ampm_2 = 'pm'; if( $human_hour == '' ) { $human_hour = 12; $ampm_2 = 'am'; } if( $human_hour > 12 ) { $human_hour -= 12; } else { $ampm_2 = 'am'; } $human_stop = "{$human_hour}:{$stoptime_arr[1]}"; if( $ampm_2 == $ampm ) { $ampm = ''; } $human_day = $GLOBALS['dayshorts'][$row_stagger['startday']]; $human_time = "{$human_start}{$ampm}-{$human_stop}{$ampm_2}"; $human_string = "{$human_day} {$human_time}"; if( $row['DJName'] != '' ) { $djpart = "
w/ {$row['DJName']} "; } else { $djpart = ""; } $file .= << {$row['showname']}{$djpart}
{$human_time} EOT; $if = "elif"; } // for through the schedule $file .= << (see schedule link) EOT; return $file; } // function emit_whatson $query = "SELECT id FROM semester ORDER BY start DESC LIMIT 1"; $res = mysql_query($query) or die(mysql_error()." -- ".$query); $row = mysql_fetch_array($res, MYSQL_ASSOC); $semester_id = $row['id']; for( $i=0; $i<5; $i++ ) { $file = fopen("whatson".($i+1).".html", "w"); $text = emit_whatson($semester_id, $i); fwrite($file, $text); fclose($file); } // for 0-5 // mysql_close($conn); ?>