Січ 052013
 

PHP Календарь

Пример создания PHP скрипта для создания календаря.

Откройте Ваш редактор и скопируйте данный скрипт.

<?php
$num_days["January"]=31;
$num_days["February"]=($leap == 1 ? 29 : 28);
$num_days["March"]=31;
$num_days["April"]=30;
$num_days["May"]=31;
$num_days["June"]=30;
$num_days["July"]=31;
$num_days["August"]=31;
$num_days["September"]=30;
$num_days["October"]=31;
$num_days["November"]=30;
$num_days["December"]=31;

$days        = Array(“Sun”,”Mon”,”Tue”,”Wed”,”Thu”,”Fri”,”Sat”);

$today_num     = $tnc = date(“j”);
$today_day    = date(“D”);

$tdc        = array_search(date(“D”),$days);

while ($tnc > 1) {
$tdc–;
if ($tdc < 0) { $tdc=6; }

$tnc–;
}

$counter_day    = $days[$tdc];
$counter_day_num= 1;
$total_days        = $num_days[date("F")];
$on    = 0;

$date_display_title=”<b>”. date(“F”).”</b> (<i><font size=1

color=green>”.date(“Y”).”</font></i>)”;

echo ”
<table border=0 cellpadding=3 cellspacing=1>
<tr><td colspan=7 >{$date_display_title}</td></tr>
<tr>
<td><b>S</b></td>
<td><b>M</b></td>
<td><b>T</b></td>
<td><b>W</b></td>
<td><b>T</b></td>
<td><b>F</b></td>
<td><b>S</b></td>
</tr>
<tr>
“;

while ($counter_day_num <= $total_days) {
if ($on > 6) { $on=0; echo “</tr><tr>”; }
if ($counter_day != $days[$on]) { echo “<td>&nbsp;</td>”; $on++; continue; }
if (isset($dull)) {
echo “<td style=’background: rgb(220,220,220);’>”;
echo “<font style=’color: grey’>{$counter_day_num}</font></td>”;
}
else {
echo “<td style=’background: rgb(230,230,230);’ align=center>”. $counter_day_num .”</td>”;
if ($counter_day_num == date(“j”)) { $dull=true; }
}

$counter_day_num++;
$next_day    =array_search($counter_day,$days) + 1;
$counter_day=$days[($next_day > 6 ? 0 : $next_day)];
$on++;
}
echo “</tr></table>”;
?>

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)