You can now hold the mouse over the schedule and it will display the name of the DJ. For Information on the show, click on that block.
time][$row->day]['dj_name']=$row->dj_name;
$tmp[$row->time][$row->day]['pid1']=$row->id;
$tmp[$row->time][$row->day]['format_name']=$row->format_name;
$tmp[$row->time][$row->day]['format']=$row->format;
$tmp[$row->time][$row->day]['color']=$row->color;
$tmp[$row->time][$row->day]['block']=1;
if (isset($row->id2)) {
$query="SELECT dj_name, id FROM wknc.profile WHERE username='$row->id2'";
$result2=db_query($query);
$row2=db_fetch_object($result2);
$tmp[$row->time][$row->day]['dj_name2']=$row2->dj_name;
$tmp[$row->time][$row->day]['pid2']=$row2->id;
}
if (isset($row->id3)) {
$query="SELECT dj_name, id FROM wknc.profile WHERE username='$row->id3'";
$result3=db_query($query);
$row3=db_fetch_object($result3);
$tmp[$row->time][$row->day]['dj_name3']=$row3->dj_name;
$tmp[$row->time][$row->day]['pid3']=$row3->id;
}
if (isset($row->id4)) {
$query="SELECT dj_name, id FROM wknc.profile WHERE username='$row->id4'";
$result4=db_query($query);
$row4=db_fetch_object($result4);
$tmp[$row->time][$row->day]['dj_name4']=$row4->dj_name;
$tmp[$row->time][$row->day]['pid4']=$row4->id;
}
}
/*************************************************************************
* Postprocess the variable structure *
**************************************************************************
* Processes the structure to find out how many rows each block will have*
* to have (rowspan=X). This is a very touchy part of the script (well, *
* it all is), be wary of the initial conditions because they make a *
* large difference. I'd say, leave it alone for sanity's sake. *
**************************************************************************/
echo("
| |
Sunday |
Monday |
Tuesday |
Wednesday |
Thursday |
Friday |
Saturday |
|
");
$last_id="foo";
$block=1;
foreach($weekdays as $wk)
{
foreach($time as $tm)
{
// Set the new DJ Name
if (isset($tmp[$tm][$wk]['pid1'])) { $new_id=$tmp[$tm][$wk]['pid1'];
}
else { $new_id=""; }
//
// Condition 1: If same DJ & time is 23:30 -> end of day!
if (($last_id == $new_id) && ($tm != 2330) ) {
$block++;
$tmp[$tm][$wk]['dj_name']="BLOCK";
}
// Condition 2: ??
elseif (( ($last_id != $new_id) || ($tm==2330) )&& ($block > 1)) {
if ($tm == 2330)
{
$block++;
$tmp[$tm][$wk]['dj_name']="BLOCK";
$tm=$tm+70;
}
$temptm=$tm-($block*50);
if( ($block%2 == 1) && ($tm%100==30) ) {
$temptm=$temptm+20;
} elseif( ($block%2 == 1) && ($tm%100==0) ) {
$temptm=$temptm-20;
}
$tmp[$temptm][$wk]['block']=$block;
$tmp[$temptm][$wk]['endtime']=$tm;
$block=1;
}
// Condition 3: ??
elseif (($last_id == $new_id) && ($tm==2330) ) {
$block++;
$tmp[$tm][$wk]['dj_name']="BLOCK";
$tm=$tm+70;
$temptm=$tm-($block*50);
if( ($block%2 == 1) && ($tm%100==30) ) {
$temptm=$temptm+20;
} elseif( ($block%2 == 1) && ($tm%100==0) ) {
$temptm=$temptm-20;
}
$tmp[$temptm][$wk]['block']=$block;
$tmp[$temptm][$wk]['endtime']=$tm;
$block=1;
}
if (isset($tmp[$tm][$wk]['pid1'])) { $last_id=$new_id; }
else { $last_id="none"; }
}
}
/*************************************************************************
* Print the schedule *
**************************************************************************
* Be careful of any changes you make. This script is very sensitive to *
* initial conditions and the flow of the script. It took me a very long*
* time to get the thing to work correctly. *
**************************************************************************/
foreach ($time as $tm) {
$new_time=format_time($tm);
if ($tm%100==0) { echo("\n\t| $new_time\n"); }
else { echo(" |
\n"); }
foreach ($weekdays as $wk)
{
if (isset($tmp[$tm][$wk]['block']))
if ($tmp[$tm][$wk]['block']>1) { $block=$tmp[$tm][$wk]['block']; }
else { $block=1; }
// Process the variables - have to do this or it will stick thousands
// of errors into the error_log
//
if (isset($tmp[$tm][$wk]['color'])) { $color=$tmp[$tm][$wk]['color']; }
else { $color="none"; }
if (isset($tmp[$tm][$wk]['endtime'])) { $endtime=$tmp[$tm][$wk]['endtime']; }
else { $endtime=""; }
if (isset($tmp[$tm][$wk]['dj_name'])) { $dj_name=$tmp[$tm][$wk]['dj_name']; }
else { $dj_name=""; }
if (isset($tmp[$tm][$wk]['modified'])) { $pid=$tmp[$tm][$wk]['pid1']; }
else { $modified=""; }
if (isset($tmp[$tm][$wk]['format_name'])) { $format_name=$tmp[$tm][$wk]['format_name']; }
else { $format_name=""; }
if (isset($tmp[$tm][$wk]['pid1'])) { $pid=$tmp[$tm][$wk]['pid1']; }
else { $pid = ""; }
$link_info="";
$dj = $link_info . $dj_name;
$dj .="";
$boxtext = $link_info . $format_name . "
" . $dj_name . "";
if (isset($tmp[$tm][$wk]['dj_name2'])) {
$pid2=$tmp[$tm][$wk]['pid2'];
$link_info="";
$temp=$link_info . $tmp[$tm][$wk]['dj_name2'] . "";
$dj .= ", " . $temp;
}
if (isset($tmp[$tm][$wk]['pid3'])) {
$pid3=$tmp[$tm][$wk]['pid3'];
$link_info="";
$temp=$link_info . $tmp[$tm][$wk]['dj_name3'] . "";
$dj .= ", " . $temp;
}
if (isset($tmp[$tm][$wk]['dj_name4'])) {
$pid4=$tmp[$tm][$wk]['pid4'];
$link_info="";
$temp=$link_info . $tmp[$tm][$wk]['dj_name4'] . "";
$dj .= ", " . $temp;
}
if (($dj_name != "BLOCK") && ($dj_name != "") ) {
echo("\t");
echo("");
echo($boxtext);
echo(" | \n");
} elseif ($dj_name=="BLOCK") {
// echo ("\t\n");
} else {
echo("\t | \n");
}
} // end foreach weekdays as wk
if ($tm%100==0) {
echo("\t $new_time");
}
echo("\n |
");
} // end foreach time as tm
echo("
");
/*************************************************************************
* S U B R O U T I N E S *
*************************************************************************
*************************************************************************
*************************************************************************
*************************************************************************/
function format_time ($hour)
{
if ($hour%100==30)
{
$minute=30;
$hour=($hour-$minute)/100;
} else {
$hour=$hour/100;
$minute=0;
$new_time=mktime($hour,$minute);
}
$new_time=mktime($hour,$minute);
$new_time=strftime("%I:%M%p",$new_time);
if (substr($new_time,0,1)=="0") { $new_time=(substr($new_time,1)); }
return $new_time;
}
?>