Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Kalendarz - problem z zakonczeniem
Forum PHP.pl > Forum > PHP
tomaszek
Witam mam taki skrypt kalendarza:

Kod
<?
  if(($month == 0) || ($year == 0)) {
   $thisDate = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
  } else {
   $thisDate = mktime(0, 0, 0, $month, 1, $year);
  }
  
if($month == 1){
$monthPrev = 12;
$monthNext = $month + 1;
$yearPrev = $year - 1;
$yearNext = $year;
}elseif($month == 12){
$monthPrev = $month - 1;
$monthNext = 1;
$yearPrev = $year;
$yearNext = $year + 1;
}else{
$monthPrev = $month - 1;
$monthNext = $month + 1;
$yearPrev = $year;
$yearNext = $year;
$yearPrevYear = $year - 1;
$yearNextYear = $year + 1;
}
  
  echo '<div style="margin-bottom: 3px;">
  
<a href="index.php?month='.$month.'&year='.$yearPrevYear.'"><</a> | <a href="index.php?month='.$monthPrev.'&year='.$yearPrev.'"><<</a> <a href="index.php?month='.$monthNext.'&year='.$yearNext.'">>></a> | <a href="index.php?month='.$month.'&year='.$yearNextYear.'">></a>
    </div>';
  
  // Display the week days.
  echo '<div class="calendarFloat" style="text-align: center; background-color: #f0f2ff;"><span style="position: relative; top: 4px;">Mon</span></div>
    <div class="calendarFloat" style="text-align: center; background-color: #f0f2ff;"><span style="position: relative; top: 4px;">Tue</span></div>
    <div class="calendarFloat" style="text-align: center; background-color: #f0f2ff;"><span style="position: relative; top: 4px;">Wed</span></div>
    <div class="calendarFloat" style="text-align: center; background-color: #f0f2ff;"><span style="position: relative; top: 4px;">Thur</span></div>
    <div class="calendarFloat" style="text-align: center; background-color: #f0f2ff;"><span style="position: relative; top: 4px;">Fri</span></div>
    <div class="calendarFloat" style="text-align: center; background-color: #CCC;"><span style="position: relative; top: 4px;">Sat</span></div>
    <div class="calendarFloat" style="text-align: center; background-color: #CCC;"><span style="position: relative; top: 4px;">Sun</span></div>';
  
                echo'<table border="0" width="100%" cellspacing="0" cellpadding="0">';
                            
    // Show the calendar.
  for($i=0; $i<date("t", $thisDate); $i++)
  {
   $thisDay = ($i + 1);
   if(($month == 0) || ($year == 0)) {
    $finalDate = mktime(0, 0, 0, date("m"), $thisDay, date("Y"));
    $today = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
    $fdf = mktime(0, 0, 0, date("m"), 1, date("Y"));
    $month = date("m");
    $year = date("Y");
   } else {
    $finalDate = mktime(0, 0, 0, $month, $thisDay, $year);
    $fdf = mktime(0, 0, 0, $month, 1, $year);
   }
  
  
   // Skip some cells to take into account for the weekdays.
   if($i == 0) {
    $firstDay = date("w", $fdf);
    $skip = ($firstDay - 1);
    if($skip < 0) { $skip = 6; }
    
    for($s=0; $s<$skip; $s++)
    {
     echo '<div class="calendarFloat" style="border: 1px solid #000000;">XXX</div>';
    }
   }
      
   // Make the weekends a darker colour.
   if((date("w", $finalDate) == 0) || (date("w", $finalDate) == 6)) {
    $bgColor = '#CCC';
   } else {
    $bgColor = '#f0f2ff';
   }
  
   // <span style="position: relative; top: '. $tTop .'; left: 1px;">'. $thisDay .'</span>
  
   // Display the day.
   echo '<div class="calendarFloat" id="calendarDay_'. $thisDay .'" style="background-color: '. $bgColor .'; cursor: pointer;"
         onMouseOver="highlightCalendarCell(\'calendarDay_'. $thisDay .'\')"
         onMouseOut="resetCalendarCell(\'calendarDay_'. $thisDay .'\')">
      <span style="position: relative; top: '. $tTop .'; left: 1px;">'. $thisDay .'</span>
     </div>';  
    
  }
          echo('</td>
                        </table>');

?>


i on działa ale nie do konca jak powinien. Problem polega na tym ze jeśli pierwszy dzien miesiąca wypada np w środe to w poniedziałek i wtorek wyświetlane jest XXX w <div> ale juz zakonczenie ostatniego tygodnia miesiąca tak nie wygląda bo jesli np ostatni dzien miesiąca wypada w piątek to w sobote i niedziele nic sie nie wyswietla. A czodzi o to zeby się wyświetlało.
okitoki
u mnie w firefox to nie wygląda jak kalendarz, tylko jak jakaś dziwna lista od 1 - 30
tomaszek
no własnie w tym problem ze u mnie firefox wygląda tak samo ale w ie wygląda tak jak opisałem na początku tematu.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.