brown2005 Posted November 4, 2009 Share Posted November 4, 2009 function draw_calendar($month,$year) { $headings = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'); $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(); $calendar = '<table cellpadding="0" cellspacing="0" class="calendar">'; $calendar.= '<tr class="calendar-row"><td class="calendar-day-head">'.implode('</td><td class="calendar-day-head">',$headings).'</td></tr>'; $calendar.= '<tr class="calendar-row">'; /* print "blank" days until the first of the current week */ for($x = 0; $x < $running_day; $x++): $calendar.= '<td class="calendar-day-np"> </td>'; $days_in_this_week++; endfor; /* keep going with days.... */ for($list_day = 1; $list_day <= $days_in_month; $list_day++): $calendar.= '<td class="calendar-day">'; /* add in the day number */ $calendar.= '<div class="day-number">'.$list_day.'</div>'; /** QUERY THE DATABASE FOR AN ENTRY FOR THIS DAY !! IF MATCHES FOUND, PRINT THEM !! **/ $calendar.= str_repeat('<p> </p>',2); $calendar.= '</td>'; if($running_day == 6): $calendar.= '</tr>'; if(($day_counter+1) != $days_in_month): $calendar.= '<tr class="calendar-row">'; 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 < : for($x = 1; $x <= (8 - $days_in_this_week); $x++): $calendar.= '<td class="calendar-day-np"> </td>'; endfor; endif; /* final row */ $calendar.= '</tr>'; $calendar.= '</table>'; return $calendar; } how can i change the above code, so that the calendar starts on a monday instead of sunday. thanks in advance Link to comment https://forums.phpfreaks.com/topic/180272-help-change-code-to-start-from-a-monday-instead-of-sunday/ Share on other sites More sharing options...
brown2005 Posted November 4, 2009 Author Share Posted November 4, 2009 anybody out there that can help please? Link to comment https://forums.phpfreaks.com/topic/180272-help-change-code-to-start-from-a-monday-instead-of-sunday/#findComment-951000 Share on other sites More sharing options...
shlumph Posted November 4, 2009 Share Posted November 4, 2009 $headings = array('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'); Link to comment https://forums.phpfreaks.com/topic/180272-help-change-code-to-start-from-a-monday-instead-of-sunday/#findComment-951031 Share on other sites More sharing options...
brown2005 Posted November 4, 2009 Author Share Posted November 4, 2009 Hi, sorry I know that part. I should of put that. But know obviously once I have changed that then the first day of the month (say November 2009 selected) is starting off on Monday when in fact it should start on a Sunday. So I need to change the script to incorporate the header changes Link to comment https://forums.phpfreaks.com/topic/180272-help-change-code-to-start-from-a-monday-instead-of-sunday/#findComment-951034 Share on other sites More sharing options...
tail Posted November 4, 2009 Share Posted November 4, 2009 Do you want the script to automatically determine which day each month should start at? It sounds like that's what you're looking for, but the way you worded it, it also sounds like you want each month to start on a certain day. Can you be more specific as to what you're looking for? Link to comment https://forums.phpfreaks.com/topic/180272-help-change-code-to-start-from-a-monday-instead-of-sunday/#findComment-951043 Share on other sites More sharing options...
brown2005 Posted November 4, 2009 Author Share Posted November 4, 2009 $running_day = date('w',mktime(0,0,0,$month,1,$year)); i changed to $running_day = date('w',mktime(0,0,0,$month,0,$year)); and it seems to have worked. http://www.allinthissite.co.uk/index.php?month=12&year=2009 Link to comment https://forums.phpfreaks.com/topic/180272-help-change-code-to-start-from-a-monday-instead-of-sunday/#findComment-951045 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.