I'm having this problem.
Notice: Undefined offset: 0 in c:\web\php4\wbmb\include\scheduletablebuilder.php on line 119
This is an iterator script.
Here is the entire code, with the problem line emphasized between comments
I had this problem before. And I just had to fix a conditional. However this time it seems all conditionals are correct, and I don't know what to do now.PHP Code:<?php
error_reporting (E_ALL);
include_once 'tablebuilder.php';
/**
* schedule table builder
*/
class scheduleTableBuilder extends rowBuilder {
/**
* private
* $schedule schedule data
*/
var $schedule;
/**
* private
* $output the xhtml output
*/
var $output;
/**
* private
* $colCount number of columns
*/
var $colCount;
/**
* private
* $timeIndex the time of 00:00:00 to keep everything synced
*/
var $timeIndex;
//! constructor
/**
* constructs scheduleTableBuilder object
*
* @param $colCount number of columns
*
* @return void
*/
function scheduleTableBuilder($colCount) {
$this->colCount = $colCount;
$this->timeIndex = strtotime("00:00:00");
}
/**
* creates the column headers
*
* @param $colCount number of columns
*/
function columnHeaders() {
switch ($this->colCount) {
// week schedule
case 5:
return '<colgroup span="1" width ="2*" class="time"></colgroup><colgroup span="7" width ="3*" class="day"></colgroup>';
break;
// day schedule
case 6:
return '<colgroup><col class="showpicture" /><col class="showinfo" /></colgroup>';
break;
}
}
/**
* suppose to add rows, but this collects all arrays for processing
* 3-dimensional array. key = days (Mon-Sun)
*
* @param $row row by row dataset to be colected
*
* @return void
*/
function addRow($row) {
$this->schedule[$row['day']][] =
array(
"name" => $row['name'],
"radioshow_id" => $row['radioshow_id'],
"showstart" => ((strtotime($row['showstart'])) - $this->timeIndex),
// 1 length = 60 minute slot
"length" => ((strtotime($row['showend'])-strtotime($row['showstart']))/3600)
);
}
/**
* this does the "heavy calculating" to arrange all timeslots
* starts at midnight and goes left to right, skipping a
* column if a show is already there, then move onto next row
*
* @return string
*/
function makeTable() {
echo '<pre>';
var_dump($this->schedule);
echo '</pre>';
$theDays = array( 'Mon' , 'Tue' , 'Wed' , 'Thu' , 'Fri' , 'Sat' , 'Sun' );
$timeSpace = array( 0 , 0 , 0 , 0 , 0 , 0 , 0 );
for($timeSlot = 0; $timeSlot < 86400; $timeSlot = $timeSlot + 3600) {
$this->output .= "<tr>\n<td>".date("g:i a", ($timeSlot + $this->timeIndex))."</td>\n";
for($i = 0; $i <= 6; $i++) {
// if there are no schedules for a whole day
if ((!array_key_exists($theDays[$i], $this->schedule)) && ($timeSpace[$i] == 0 )) {
$this->output .= '<td rowspan="24">empty</td>';
$timeSpace[$i] = $timeSpace[$i] + 86400;
}
// something is already there
if ($timeSpace[$i] > $timeSlot) {
// if there isn't anything there
} elseif ($timeSpace[$i] == $timeSlot) {
// a show schedule fits
// -----------------------------------------------------
// -------------problem is on this line------------
// -----------------------------------------------------
if ($this->schedule[$theDays[$i]][0]['showstart'] == $timeSpace[$i]) {
// -----------------------------------------------------
// -----------------------------------------------------
// -----------------------------------------------------
$this->output .= '<td rowspan="'.$this->schedule[$theDays[$i]][0]['length'].'"><a href="show.php?id='.$this->schedule[$theDays[$i]][0]['radioshow_id'].'">'.$this->schedule[$theDays[$i]][0]['name'].'</a></td>'."\n";
$timeSpace[$i] = $timeSpace[$i] + (3600*$this->schedule[$theDays[$i]][0]['length']);
array_shift($this->schedule[$theDays[$i]]);
// no schedule information left, but timeslots not filled
} elseif ((empty($this->schedule[$theDays[$i]][0])) && ($timeSpace[$i] < 86400)) {
$slotsLeft = ((86400 - $timeSpace[$i])/3600);
$this->output .= '<td rowspan="'.$slotsLeft.'">empty</td>'."\n";
// next schedule is far ahead
} elseif ($this->schedule[$theDays[$i]][0]['showstart'] > $timeSpace[$i]) {
$slotsLeft = (($this->schedule[$theDays[$i]][0]['showstart'] - $timeSpace[$i])/(3600));
$this->output .= '<td rowspan="'.$slotsLeft.'">empty</td>'."\n";
$timeSpace[$i] = $timeSpace[$i] + (3600*$this->schedule[$theDays[$i]][0]['length']);
}
}
}
$this->output .= "</tr>\n";
}
$this->output .= '</table>';
}
/**
* takes property $schedule and forms an output
*/
function tableEnder() {
$this->makeTable();
return $this->output;
}
/**
* return timeIndex
*/
function timeIndex() {
return $this->timeIndex;
}
}
?>




Bookmarks