Help building diary
Posted: Tue Apr 08, 2003 5:17 pm
I needsome help buiding a diary. I am using an exist .php class to do this, but there is no mention of how to get the details of the events into a displayed date. So far from the diary view script I can produce the linked date array and the event array, but will I can show the day in the table cell I cannot get the event id and description in it. Is there some way of matching the array pointers so that the correct event id and description is shown?
date Array
(
[0] => 05
[1] => 6
[2] => 7
[3] => 17
[4] => 18
)
event Array
(
[0] => 3
[1] => 3
[2] => 3
[3] => 4
[4] => 4
)
calendar class:
date Array
(
[0] => 05
[1] => 6
[2] => 7
[3] => 17
[4] => 18
)
event Array
(
[0] => 3
[1] => 3
[2] => 3
[3] => 4
[4] => 4
)
calendar class:
Code: Select all
<?php
function build_calendar($month,$year,$dateArray) {
$daysOfWeek = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
$firstDayOfMonth = mktime (0,0,0,$month,1,$year);
$numberDays = date ('t',$firstDayOfMonth);
$dateComponents = getdate($firstDayOfMonth);
$monthName = $dateComponents['month'];
$dayOfWeek = $dateComponents['wday'];
$calendar = "<table class='calendar'>";
//$calendar .= "<caption>$monthName, $year</caption>";
//$calendar .= "<tr>";
foreach($daysOfWeek as $day) {
$calendar .= "<th class='header'>$day</th>";
}
$currentDay = 1;
$calendar .= "</tr><tr>";
if ($dayOfWeek > 0) {
$calendar .= "<td colspan='$dayOfWeek'> </td>";
}
while ($currentDay <= $numberDays) {
if ($dayOfWeek == 7) {
$dayOfWeek = 0;
$calendar .= "</tr><tr>";
}
//this is the bit i am looking at------------------------------------------------
if (in_array($currentDay,$dateArray)) {
$date = "$year-$month-$currentDay";
$calendar .= "<td class='linkedday' width='150' height='75'>
<a href='dwelcome.php?date=$date'
class='calendarlink'>$currentDay</a><p>$cal_idArray</p></td>";
//---------------------------------------------------------------------------------
} else {
$monthday = "$year-$month-$currentDay";
$calendar .= "<td class='day' width='150' height='75'>
<a href='dwelcome.php?date=$monthday'
class='calendarlink'>$currentDay</a></td>";
}
$currentDay++;
$dayOfWeek++;
}
if ($dayOfWeek != 7) {
$remainingDays = 7 - $dayOfWeek;
$calendar .= "<td colspan='$remainingDays'> </td>";
}
$calendar .= "</table>";
return $calendar;
}
?>