Skip to content

Instantly share code, notes, and snippets.

@phpfour
Created May 20, 2013 18:50
Show Gist options
  • Save phpfour/5614383 to your computer and use it in GitHub Desktop.
Save phpfour/5614383 to your computer and use it in GitHub Desktop.
<?php
//Draw Calendar
function draw_calendar($month,$year){
// Draw table for Calendar
$calendar = '';
// Draw Calendar table headings
$headings = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
$calendar.= '';
//days and weeks variable for now ...
$running_day = date('w',mktime(0,0,0,$month,1,$year));
$days_in_month = date('t',mktime(0,0,0,$month,1,$year));
$days_in_this_week = 1;
$day_counter = 0;
$dates_array = array();
// row for week one
$calendar.= '';
// Display "blank" days until the first of the current week
for($x = 0; $x < $running_day; $x++):
$calendar.= '';
$days_in_this_week++;
endfor;
// Show days....
for($list_day = 1; $list_day <= $days_in_month; $list_day++):
if($list_day==date('d') && $month==date('n')) {
$currentday='currentday';
} else {
$currentday='';
}
$calendar.= '';
if($running_day == 6):
$calendar.= '';
if(($day_counter+1) != $days_in_month):
$calendar.= '';
endif;
$running_day = -1;
$days_in_this_week = 0;
endif;
$days_in_this_week++; $running_day++; $day_counter++;
endfor;
// Finish the rest of the days in the week
if($days_in_this_week < 8):
for($x = 1; $x <= (8 - $days_in_this_week); $x++):
$calendar.= '';
endfor;
endif;
// Draw table final row
$calendar.= '';
// Draw table end the table
$calendar.= '<table cellpadding="0" cellspacing="0" class="calendar"><tbody><tr class="calendar-row"><td class="calendar-day-head">'.implode('</td><td class="calendar-day-head">',$headings).'</td></tr><tr class="calendar-row"><td class="calendar-day-np"> </td><td class="calendar-day '.$currentday.'">';
// Add in the day number
if($list_day<date('d') &&="" $month="=date('n'))" {="" $showtoday="<strong class="overday">" .$list_day.'<="" strong="">';
}else {
$showtoday=$list_day;
}
$calendar.= '<div class="day-number">'.$showtoday.'</div>';
// Draw table end
$calendar.= '</date('d')></td></tr><tr class="calendar-row"><td class="calendar-day-np"> </td></tr></tbody></table>';
// Finally all done, return result
return $calendar;
}
@agarzon
Copy link

agarzon commented Oct 21, 2013

Parse error: syntax error, unexpected '=' in /var/www/agarzon/calendar.php on line 62

@xeoncross
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment