Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Kalendarz i polskie nazwy m-cy
Forum PHP.pl > Forum > PHP
xarkez
Witam. Mam taki kodzik kalendarza oparty na PHP i MYSQL ( eventy )
Mam problem z polskimi nazwami m-cy. Próbowałem już na wiele sposobów ale bez rezultatu. Może ktoś tutaj mi pomoże biggrin.gif

  1. <?php
  2. include("../db_data.php");
  3.  
  4.  
  5. /// get current month and year and store them in $cMonth and $cYear variables
  6. (intval($_REQUEST["month"])>0) ? $cMonth = intval($_REQUEST["month"]) : $cMonth = date("m");
  7. (intval($_REQUEST["year"])>0) ? $cYear = intval($_REQUEST["year"]) : $cYear = date("Y");
  8.  
  9. // generate an array with all dates with events
  10. $sql = "SELECT * FROM event_calendar WHERE `event_date` LIKE '".$cYear."-".$cMonth."-%'";
  11. $sql_result = mysql_query ($sql, $mysql_link ) or die ('request "Could not execute SQL query" '.$sql);
  12. while ($row = mysql_fetch_assoc($sql_result)) {
  13. $events[$row["event_date"]]["title"] = $row["title"];
  14. $events[$row["event_date"]]["description"] = $row["description"];
  15. }
  16.  
  17. // calculate next and prev month and year used for next / prev month navigation links and store them in respective variables
  18. $prev_year = $cYear;
  19. $next_year = $cYear;
  20. $prev_month = intval($cMonth)-1;
  21. $next_month = intval($cMonth)+1;
  22.  
  23. // if current month is December or January month navigation links have to be updated to point to next / prev years
  24. if ($cMonth == 12 ) {
  25. $next_month = 1;
  26. $next_year = $cYear + 1;
  27. } elseif ($cMonth == 1 ) {
  28. $prev_month = 12;
  29. $prev_year = $cYear - 1;
  30. }
  31.  
  32. if ($prev_month<10) $prev_month = '0'.$prev_month;
  33. if ($next_month<10) $next_month = '0'.$next_month;
  34. ?>
  35. <table width="100%">
  36. <tr>
  37. <td class="mNav-left"><a href="java script:LoadMonth('<?php echo $prev_month; ?>', '<?php echo $prev_year; ?>')">&lt;&lt;</a></td>
  38. <td colspan="5" class="cMonth"><?php echo date("F, Y",strtotime($cYear."-".$cMonth."-01")); ?></td>
  39. <td class="mNav-right"><a href="java script:LoadMonth('<?php echo $next_month; ?>', '<?php echo $next_year; ?>')">&gt;&gt;</a></td>
  40. </tr>
  41. <tr>
  42. <td class="wDays">Poniedziałek</td>
  43. <td class="wDays">Wtorek</td>
  44. <td class="wDays">Środa</td>
  45. <td class="wDays">Czwartek</td>
  46. <td class="wDays">Piątek</td>
  47. <td class="wDays">Sobota</td>
  48. <td class="wDays">Niedziela</td>
  49. </tr>
  50. <?php
  51. $first_day_timestamp = mktime(0,0,0,$cMonth,1,$cYear); // time stamp for first day of the month used to calculate
  52. $maxday = date("t",$first_day_timestamp); // number of days in current month
  53. $thismonth = getdate($first_day_timestamp); // find out which day of the week the first date of the month is
  54. $startday = $thismonth['wday'] - 1; // 0 is for Sunday and as we want week to start on Mon we subtract 1
  55.  
  56. for ($i=0; $i<($maxday+$startday); $i++) {
  57.  
  58. if (($i % 7) == 0 ) echo "<tr>";
  59.  
  60. if ($i < $startday) { echo "<td>&nbsp;</td>"; continue; };
  61.  
  62. $current_day = $i - $startday + 1;
  63. if ($current_day<10) $current_day = '0'.$current_day;
  64.  
  65. // set css class name based on number of events for that day
  66. if ($events[$cYear."-".$cMonth."-".$current_day]<>'') {
  67. $css='withevent';
  68. $click = "onclick=\"LoadEvents('".$cYear."-".$cMonth."-".$current_day."')\"";
  69. } else {
  70. $css='noevent';
  71. $click = '';
  72. }
  73.  
  74. echo "<td class='".$css."'".$click.">". $current_day . "</td>";
  75.  
  76. if (($i % 7) == 6 ) echo "</tr>";
  77. }
  78. ?>
  79. </table>
emstawicki
Jaki masz problem i gdzie występuje, bo wg. mnie wrzesień ostatnio jest krótki?
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.