note 105654 deleted from function.date by tularis

From: Date: Thu, 09 Feb 2012 20:49:12 +0000
Subject: note 105654 deleted from function.date by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-185949@lists.php.net to get a copy of this message
Note Submitter: gothamxi at gmail dot com ---- simple calendar generator: <?php $dw=date(N);//this day of the week, numeric $d=date(j);//this date $m=date(m);//this month $y=date(o);//this year echo "<div id='CALENDAR DIV'><span style='font-size:20px;display:block;width:100%;text-align:center;'>"; echo date("F",mktime(0, 0, 0, $m, 1, $y)); echo "</span><table style='border:2px solid black;border-collapse:collapse;'>"; function mlength($month,$year){ return cal_days_in_month(CAL_GREGORIAN, $month, $year);//finds length of given month } $tml=mlength($m,$y);//this month's length $cc=1;//day of the week counter $day=1; $tmd1=date("N", mktime(0, 0, 0, $m, 1, $y));//this month day 1, day of the week, numeric //write out calendar--------------------------------------------------------------------- //days of the week $dwcc=1;//counter for days of the week row while($dwcc<=7){ $dwrow.="<td style='padding:15px;width:150px;height:auto;border:2px solid #333;' >".date("l", mktime(0, 0, 0, 8, $dwcc, 2011))."</td>\r\n"; $dwcc=$dwcc+1; } $tblrows="<tr>\r\n".$dwrow."\r\n</tr>\r\n\r\n"; //last days of last month if($tmd1!=1){ while($cc<$tmd1){ $tblrows.=(($cc==1)?"<tr>\r\n":"")."<td style='padding:15px;width:150px;height:150px;border:2px solid black;' >&nbsp;</td>\r\n"; $cc=($cc==7)?1:$cc+1; } } //this month while($day<=$tml){ $tblrows.=(($cc==1)?"<tr>\r\n":"")."<td style='padding:15px;width:150px;height:150px;border:2px solid black;".(($day==$d)?"background-color:#999;":"")."' >".$day."</td>\r\n".(($cc==7)?"\r\n</tr>\r\n\r\n":""); $cc=($cc==7)?1:$cc+1; $day=$day+1; } //first days of next month if($cc!=7){ while($cc<=7){ $tblrows.="<td style='padding:15px;width:150px;height:150px;border:2px solid black;' >&nbsp;</td>\r\n".(($cc==7)?"\r\n</tr>\r\n\r\n":""); $cc=$cc+1; } } echo $tblrows; echo "</table></div>"; ?>

« previous php.notes (#185949) next »