In questo tutorial imparerete come creare un favoloso calendario in PHP!

 
< ?php
 
if($_GET[‘month’]) {
$month = $_GET[‘month’];
}
else {
$month = date(‘n’);
$_GET[‘month’] = date(‘n’);
}
if($_GET[‘year’]) {
$year = $_GET[‘year’];
}
else {
$year = date(‘Y’); // Year
$_GET[‘year’] = date(‘Y’);
}
 
$firstday = mktime(0, 0, 0, $month, 1, $year);
$number = cal_days_in_month(CAL_GREGORIAN, $month, $year); // Number of Days in a Month
$title = date(‘F’, $firstday); // Month name
$day = date(‘D’, $firstday);
 
if($day == "Sun") {
$before = "0";
}
elseif($day == "Mon") {
$before = "1";
}
 
elseif($day == "Tue") {
$before = "2";
}
 
elseif($day == "Wed") {
$before = "3";
}
 
elseif($day == "Thu") {
$before = "4";
}
 
elseif($day == "Fri") {
$before = "5";
}
 
elseif($day == "Sat") {
$before = "6";
}
 
if($_GET[‘month’] == 12) {
$nextmonth = 1;
$previousmonth = $_GET[‘month’]1;
$nextyear = $_GET[‘year’] + 1;
$previousyear = $_GET[‘year’];
}
 
elseif($_GET[‘month’] == 1) {
$previousmonth = 12;
$nextmonth = $_GET[‘month’] + 1;
$previousyear = $_GET[‘year’]1;
$nextyear = $_GET[‘year’];
}
 
else {
$nextmonth = $_GET[‘month’] + 1;
$previousmonth = $_GET[‘month’]1;
$nextyear = $_GET[‘year’];
$previousyear = $_GET[‘year’];
}
 
echo"&laquo;";
echo"&nbsp; $title $year &nbsp;";
echo"&raquo;";
 
$i = 1;
$real = 1 + $before;
 
echo"

";
while($before > 0) {
echo"

 
";
$before;
}
 
while($i < = $number) {
 
echo"
$i "
;
 
$divide = $real / 7;
if(is_int($divide)) {
echo"
"
;
}
++$real;
++$i;
}
 
echo"

 
";
 
?>
 

fonte: www.sastgroup.com