Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.

Thread Tools Display Modes
Share |
Old 06-19-2014, 03:12 AM
kontrol's Avatar
kontrol kontrol is offline
Contributing Member
Join Date: 02-10-10
Posts: 225
iTrader: 0 / 0%
help with calendar

my calendar displays nicely as required but that dates don't change. when a month is 31 days, it still remains at 30 and always starting from Tuesday.

PHP Code:
/* draws a calendar */
function draw_calendar($month,$year){

/* draw table */
$calendar '<table cellpadding="0" cellspacing="0" class="calendar">';

/* table headings */
$headings = array('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
$calendar.= '<tr class="calendar-row"><td class="calendar-day-head">'.implode('</td><td class="calendar-day-head">',$headings).'</td></tr>';

/* days and weeks vars 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.= '<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>';

/* 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>';

$calendar.= str_repeat('<p> </p>',2);
$calendar.= '</td>';
$running_day == 6):
$calendar.= '</tr>';
$day_counter+1) != $days_in_month):
$calendar.= '<tr class="calendar-row">';
$running_day = -1;
$days_in_this_week 0;
$days_in_this_week++; $running_day++; $day_counter++;

/* finish the rest of the days in the week */
if($days_in_this_week 8):
$x 1$x <= ($days_in_this_week); $x++):
$calendar.= '<td class="calendar-day-np"> </td>';

/* final row */
$calendar.= '</tr>';

/* end the table */
$calendar.= '</table>';
/* all done, return result */
return $calendar;

/* sample usages */
echo "<h2>".date('F, Y')."</h2>";
"<br /><hr/>";
Reply With Quote



Old 06-19-2014, 03:19 AM
gmmiso88 gmmiso88 is offline
Junior Member
Join Date: 06-19-14
Posts: 19
iTrader: 0 / 0%
You can store the month's dates in an array like this.
$month_days= array(31,28,31,30,31,30,31,31,30,31,30,31);
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Calendar TarHeel Coding Forum 2 10-12-2012 08:48 AM
php calendar simi Coding Forum 4 04-15-2011 07:50 AM
Need a Free PHP Calendar Immo Coding Forum 2 01-14-2008 07:09 AM
V7N Calendar John Scott Forum Lobby 9 01-09-2007 08:43 AM

V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory

All times are GMT -7. The time now is 04:55 PM.
Powered by vBulletin
Copyright 2000-2014 Jelsoft Enterprises Limited.
Copyright © 2003 - 2018 VIX-WomensForum LLC