Hi chorn… thanks for your response. I’m trying to use a loop to mark the first 5 days using $k). I modified the public function show() like this:
(I added " for ($k = 1; $k <= 5; $k++) { $content .= $this->_showBirthdays($i * 7 + $j, $k); } ")
and also created the _showBirthdays() like this:
(" private function _showBirthdays($cellNumber, $k)
{
if ($this->currentDay == 0) {
$firstDayOfTheWeek = date(‘N’, strtotime($this->currentYear . ‘-’ . $this->currentMonth . ‘-01’));
if (intval($cellNumber) == intval($firstDayOfTheWeek)) {
$this->currentDay = 1;
}
}
if (($this->currentDay != 0) && ($this->currentDay <= $this->daysInMonth)) {
$this->currentDate = date(‘Y-m-d’, strtotime($this->currentYear . ‘-’ . $this->currentMonth . ‘-’ . ($this->currentDay)));
$cellContent = $this->currentDay;
$this->currentDay++;
} else {
$this->currentDate = null;
$cellContent = null;
}
$today_day = $k;//date(“d”);
$today_mon = date(“m”);
$today_yea = date(“Y”);
$class_day = ($cellContent == $today_day && $this->currentMonth == $today_mon && $this->currentYear == $today_yea ? “calendar_today” : “calendar_days”);
return ‘
’ . $cellContent . ‘
’ . “\r\n”;
}")
but the new loop I created seems to do everything 5 times (especially print the entire
calendar 5x)
My Code:
public function show()
{
$year = null;
$month = null;
if (null == $year && isset($_GET[‘year’])) {
$year = htmlentities($_GET[‘year’], ENT_QUOTES);
} elseif (null == $year) {
$year = date(“Y”, time());
}
if ((!is_numeric($year)) || ($year == “”)) {
$year = date(“Y”, time());
}
if (null == $month && isset($_GET[‘month’])) {
$month = htmlentities($_GET[‘month’], ENT_QUOTES);
} elseif (null == $month) {
$month = date(“m”, time());
}
if ((!is_numeric($month)) || ($month == “”)) {
$month = date(“m”, time());
}
$this->currentYear = $year;
$this->currentMonth = $month;
$this->daysInMonth = $this->_daysInMonth($month, $year);
$content = ‘
’ . “\r\n” . ‘
’ . “\r\n” . $this->_createNavi() . “\r\n” . ‘
’ . “\r\n” . ‘
’ . “\r\n” . ‘
’ . “\r\n” . $this->_createLabels() . ‘
’ . “\r\n”;
$content .= ‘
’ . “\r\n”;
$content .= ‘
’ . “\r\n”;
$weeksInMonth = $this->_weeksInMonth($month, $year);
// Create weeks in a month
for ($i = 0; $i < $weeksInMonth; $i++) {
// Create days in a week
for ($j = 1; $j <= 7; $j++) {
//$content .= $this->_showDay($i * 7 + $j);
for ($k = 1; $k <= 5; $k++) {
$content .= $this->_showBirthdays($i * 7 + $j, $k);
}
}
}
$content .= '</div>' . "\r\n";
$content .= '<div class="calendar_clear"></div>' . "\r\n";
$content .= '</div>' . "\r\n";
$content .= '</div>' . "\r\n";
return $content;
}