Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] problem z wyswietlaniem dni w kalendarzu
airendriu
post 31.07.2007, 17:46:04
Post #1





Grupa: Zarejestrowani
Postów: 4
Pomógł: 0
Dołączył: 1.05.2007

Ostrzeżenie: (0%)
-----


Witam,
Mam problem z odpowiednim wyświetlaniem dni w kalendarzu. Wszystkie dni wyświetlają się od poniedziałku =/ to samo tyczy się następnych i poprzednich miesięcy wszystkie zaczynają się tak samo.




  1. <?
  2.  
  3. function wyswietl_grafik()
  4. {
  5.  
  6. $date = time();
  7. $day = date("d", $date);
  8. $month = date("m", $date);
  9. $year = date("Y", $date);
  10.  
  11.  
  12. $first_day = mktime(0,0,0,$month, 1, $year);
  13. $day_of_week = date("D", $first_day);
  14.  
  15.  
  16.  
  17. if (isset($_GET['calendarSetting'])) 
  18. {
  19.  
  20.  $dateComponents = explode("-",$_GET['calendarSetting']); 
  21.  
  22.  $month = $dateComponents[1];
  23.  $year = $dateComponents[0];
  24. }
  25.  
  26. else 
  27. {
  28.  
  29.  $dateComponents = getdate(); 
  30.  
  31.  $month = $dateComponents['mon'];
  32.  $year = $dateComponents['year'];
  33.  
  34. }
  35.  
  36.  
  37.  
  38.  
  39. if ( (($month < 8) && ($month % 2 == 1)) || (($month > 7) && ($month % 2 == 0)) ) { $days_in_month = 31; }
  40.  
  41. if ( (($month < 8) && ($month % 2 == 0)) || (($month > 7) && ($month % 2 == 1)) ) { $days_in_month = 30; }
  42.  
  43. if (($month == 2) && ($year % 4 == 0)) { $days_in_month = 29 ;}
  44. if (($month == 2) && ($year % 4 >= 1)) { $days_in_month = 28 ;}
  45.  
  46. if($month == 1) { $prevMonth=12; $prevYear=($year-1); } else { $prevMonth=($month-1); $prevYear=$year;}
  47. if($month == 12) { $nextMonth=1; $nextYear=($year+1); } else { $nextMonth=($month+1); $nextYear=$year;}
  48.  
  49.  
  50. echo "<table border="1" cellpadding="10" cellspacing="4" align="center" style="background: #aaa; color: #000; text-align: center" width="420">
  51. <tr>
  52. <td colspan="7" style="background: #ddd; color: #00d;"><strong><a href="?calendarSetting=$prevYear-$prevMonth"><<</a> $month, $year, <a href="?calendarSetting=$nextYear-$nextMonth">>> </strong></td>
  53.  
  54.  
  55. </tr>
  56. <tr>
  57. <td style="background: #eee; color: #000" width="60"><strong>Pon.</strong></td>
  58. <td style="background: #eee; color: #000" width="60"><strong>Wto.</strong></td>
  59. <td style="background: #eee; color: #000" width="60"><strong>Sro.</strong></td>
  60. <td style="background: #eee; color: #000" width="60"><strong>Czw.</strong></td>
  61. <td style="background: #eee; color: #000" width="60"><strong>Pia.</strong></td>
  62. <td style="background: #eee; color: #000" width="60"><strong>Sob.</strong></td>
  63. <td style="background: #eee; color: #000" width="60"><strong>Nie.</strong></td>
  64. </tr>";
  65.  
  66.  
  67. $day_count = 1;
  68. $day_number = 1;
  69.  
  70.  
  71.  
  72. while($day_number <= $days_in_month) 
  73. {
  74. if($day_number < $day) 
  75. {
  76. echo "<td style="background: #bbb; border: 2px solid #ccc; color: #000"><em><a href= >$day_number</em></td>";
  77. }
  78. elseif($day_number == $day) 
  79. {
  80. echo "<td style="background: #fff; border: 2px solid #555; color: #000"><strong><a href= >$day_number</strong></td>";
  81. }
  82. else 
  83. {
  84. echo "<td style="background: #ccc; border: 2px solid #ddd; color: #000"><a href=>$day_number </td>";
  85. }
  86.  
  87. $day_number++;
  88. $day_count++;
  89.  
  90. if($day_count > 7) 
  91. {
  92. echo "</tr><tr>";
  93. $day_count = 1;
  94. }
  95. }
  96.  
  97. while($day_count > 1 && $day_count <= 7) 
  98. {
  99. echo "<td></td>"; 
  100. $day_count++;
  101. }
  102.  
  103. echo "</tr></table>";
  104. };
  105.  
  106.  
  107. wyswietl_grafik();
  108.  
  109. ?>


Może ktoś pomóc??
Dzięki
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 13.06.2025 - 18:09