hi there. i'm trying to get my output to print to a table-- Two Calendar Weeks-- using an array from MySQL output.
main ISSUES:
1.) not every "date" is populated w/ data (i.e. no event on every day)
2.) "blank" < td > cells
how to iterate over the data, populating the cells with data where appropriate, matching, for example the MySQL DATE_FORMAT('calendar', %w) value (shown below as array[key]['weekday'] ) with the Sun=0, Mon=1, etc "columns" of the table
this is what i have. it works EXCEPT for the fact that my dates do NOT "line-up" if there are "empty" cells. i have been at this thing, literally, for days-- and can not come up w/ anything to get it to work right. the following is the closest i've come.
$maindata = new calData();
// $htmltable = array();
$straightWeeks = array();
$twoWeeks = array();
for($i=0;$i<=13;$i++) {
// ( im told theres a better way to make use of the Class here )
// ( i'm curious to solve that but not main issue here)
$twoWeeks[$i] = $maindata->selectPeriod($table,$field,$order,$i);
// data SELECTION IS BASED ON $TWOWEEKS[ - KEY -]
// its relationship to the 'weekday' value,
// miraculously allows for this (so far):
if ($i>=6){
$keyup = $twoWeeks[$i]['weekday'];
$keyup = $keyup+10;
$straightWeeks[$keyup]=$twoWeeks[$i];
} else {
$keyup = $twoWeeks[$i]['weekday'];
$straightWeeks[$keyup]=$twoWeeks[$i];
}
}
$casenum = 0;
$htmltable = "<tbody>";
$xy=0;
$emptyCounter = $twoWeeks;
foreach($twoWeeks as $testday[]) {
if($testday[$xy]['event'] != ""){
/*
* IF THE EVENT IS -NOT- EQUAL TO NULL
* CHECK FOR WEEKDAY# BEING EQUAL TO A CASE#
* (i.e. If there is DATA (yes),
* then Determine which TD to put it in.
*/
switch($testday[$xy]['weekday']) {
/*
* THE SWITCH IS BASED ON WEEKDAY NUMBER VALUE
* DO WE MATCH THE WEEKDAY NUMBER VALUE
*/
case "0":
$htmltable .= '<td class="debugred">'.$twoWeeks[$xy]['event'].'<br />'.$testday[$xy]['dayof'].'</td>';
break;
case "1":
$htmltable .= '<td class="debugred">'.$twoWeeks[$xy]['event'].'<br />'.$testday[$xy]['dayof'].'</td>';
break;
case "2":
$htmltable .= '<td class="debugred">'.$twoWeeks[$xy]['event'].'<br />'.$testday[$xy]['dayof'].'</td>';
break;
case "3":
$htmltable .= '<td class="debugred">'.$twoWeeks[$xy]['event'].'<br />'.$testday[$xy]['dayof'].'</td>';
break;
case "4":
$htmltable .= '<td class="debugred">'.$twoWeeks[$xy]['event'].'<br />'.$testday[$xy]['dayof'].'</td>';
break;
case "5":
$htmltable .= '<td class="debugred">'.$twoWeeks[$xy]['event'].'<br />'.$testday[$xy]['dayof'].'</td>';
break;
case "6":
$htmltable .= '<td class="debugred">'.$twoWeeks[$xy]['event'].'<br />'.$testday[$xy]['dayof'].'</td></tr>';
break;
default:
$htmltable .= '<td class="debugblue">sorry, no value</td>';
} // end of switch
$casenum++;
} // end of IF
$xy++;
}
$htmltable .= "</tbody>";
(illustration to follow if i get to it. 🙂
thank you!!