Tutorials Infos - Anleitungen - Hilfe - Dreamcodes
 

Jahreskalender

Dieses Script zeigt euch, wie ein simpler Kalender erstellt wird

Script:

<?php
   $today
= date(d);
   
$days = date(t);
   
$month = date(m);
   
$year = date(y);
   
$firstday = mktime(0,0,1,$month,1,$year);
   
$lastday = mktime(0,0,1,$month,$days,$year);
   
$first = date(w,$firstday);
   
$last = date(w,$lastday);
   
$diff = 7-$last;
   
$jahr = date(Y);

   
$months = array("Januar", "Februar", "März", "April", "Mai", "Juni",
                   
"Juli", "August", "September", "Oktober", "November", "Dezember");
   
$monat  = $months[date("n", time())-1];

   if(
$first == 0) $first = 7;
   if(
$last == 0) $last = 7;

   for(
$i=1;$i<$first;$i++) {
      
$begin.= "<td></td>";
   }

   for(
$i=0;$i<$diff;$i++) {
      
$end.= "<td></td>";
   }

   echo
"<table border= '0' cellspacing= '0 ' cellpadding= '0 '>
         <colgroup>
            <col width= '22 '>
            <col width= '22 '>
            <col width= '22 '>
            <col width= '22 '>
            <col width= '22 '>
            <col width= '22 '>
            <col width= '22 '>
         </colgroup>
        <tr bgcolor= '#FFCC00 '>
           <th>Mo</th>
           <th>Di</th>
           <th>Mi</th>
           <th>Do</th>
           <th>Fr</th>
           <th>Sa</th>
           <th>So</th>
        </tr><tr>
        $begin"
;

   for(
$i=1;$i<($days+1);$i++) {
      if(
$first==0):
         echo
"<tr>";endif;

      if(
$i == $today) {
         echo
"<td bgcolor='#CCCCCC' align='center'>$i</td>";
      }
      else {
         echo
"<td align= 'center'>$i</td>";
      }

      if(
$first==7):
         echo
"</tr>";
         
$first=0;
      endif;

      
$first++;      

   }

   echo
"$end</tr>";
   echo
"<tr bgcolor='#FFCC00'><td colspan='7' align='center'><b>$monat $jahr</b></td></tr>";
   echo
"</table>";

?>

 
ID: 325
eingestellt am: 13.03.2004
Autor: CSN
Status zum lesen: Gast
gelesen: 8841
Webseite: www.dreamcodes.com
[Drucken]