Created
May 20, 2013 18:50
-
-
Save phpfour/5614383 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Parse error: syntax error, unexpected '=' in /var/www/agarzon/calendar.php on line 62