Kalender, vil ikke vise udtræk fra DB i december måned
Hej alleJeg har et lille spørgsmål som går på noget med at der i den aktuelle database er lagt indhold ind, og det virker fint og vises på alle måneder undtaget December måned.
Jeg kan ikke lige gennemskue hvor det er den går gal, og håber I kan hjælpe mig lidt.
Som det ses her er indholdet i databasen:
http://graensekvadrillen.dk/calendarscript.php?show_event=true&event_date=2010-12-13
Men det vises ikke i selve kalenderen på websiden (højre spalte):
http://graensekvadrillen.dk/invitation.php?&date=12-2010
Kan I se hvad eller hvor det er gået galt i dette script her:
ps. jeg tror det er nede omkring linie 92 at fejlen med tællingen opstår, men kan simpelthen ikke finde det?
---------------------PHP
<?php
$calendar_script = "calendarscript.php"; //The location of this script
$calendar_language = "uk"; //The extension of the calendar language file.
$content_background_color = "#EEEEEE"; //Background color of the column
$content_font_color = "#000000"; //The font color
$content_font_size = 10; //Font-size in pixels
$content_font_style = "normal"; //Set to italic or normal
$content_font_weight = "normal"; //Set to bold or normal
$today_background_color = "white"; //Background color of the column
$today_font_color = "green"; //The font color
$today_font_size = 10; //Font-size in pixels
$today_font_style = "normal"; //Set to italic or normal
$today_font_weight = "bold"; //Set to bold or normal
$event_background_color = "#DDDDDD"; //Background color of the column
$event_background_color2 = "#EEEEEE"; //Background color of the 2nd column (event popup)
$event_font_color = "#ffffff"; //The font color
$event_font_size = 10; //Font-size in pixels
$event_font_style = "normal"; //Set to italic or normal
$event_font_weight = "bold"; //Set to bold or normal
$event_popup_width = "350"; //Width of the popup for the events
$event_popup_height = "300"; //Height of the popup for the events
$head_background_color = "#DDDDDD"; //Background color of the column
$head_font_color = "#cc3300"; //The font color
$head_font_size = 11; //Font-size in pixels
$head_font_style = "normal"; //Set to italic or normal
$head_font_weight = "bold"; //Set to bold or normal
//darussol: CSS OPTIONS FOR WEEK DAYS
$days_head_background_color = "#DDDDDD"; //Background color of the column
$days_head_font_color = "#cc3300"; //The font color
$days_head_font_size = 11; //Font-size in pixels
$days_head_font_style = "normal"; //Set to italic or normal
$days_head_font_weight = "bold"; //Set to bold or normal
$table_border = 0; //The border of the table
$table_cellspacing = 1; //Cellspacing of the table
$table_cellpadding = 2; //Cellpadding of the table
$table_width = ''; //Table width in pixels or %'s
$table_height = ''; //Table height in pixels or %'s
$head_link_color = "#cc3300"; //The color of the link for previous/next month
$font_family = "Verdana";
$events_from_database = true;
$database = "MIT DATABASE";
$server = "MIN SERVER";
$username = "MIT BRUGERNAVN";
$password = "MIT PASSWORD";
$event_table = "calendar";
$language_file = "calendar." . $calendar_language; //Language file into variable
$fd = fopen( $language_file, "r" ); //Open the language file
$fd = fread( $fd, filesize( $language_file ) ); //Read the opened file
$language_array = explode( "\n" , $fd ); //Put file info into array
$dayname = array_slice($language_array,0,7); //The names of the days
$monthname = array_slice($language_array,7); //The rest of the language file are the monthnames
if( isset( $_GET['date'] ) )
list($month,$year) = explode("-",$_GET['date']);
else
{
$month = date("m");
$year = date("Y");
}
$date_string = mktime(0,0,0,$month,1,$year);
$day_start = date("w",$date_string);
$QUERY_STRING = preg_replace("/&date=".$month."-".$year."/","",$_SERVER['QUERY_STRING']);
if( $month < 12 )
{
$next_month = $month+1;
$next_date = $next_month."-".$year;
}
else
{
$next_year = $year+1;
$next_date = "1-".$next_year;
$next_month = 1;
}
if( $month > 1 )
{
$previous_month = $month-1;
$next_month = $month+1;
$previous_date = $previous_month."-".$year;
}
else
{
$previous_year = $year-1;
$previous_date = "12-".$previous_year;
$previous_month = 12;
}
$table_caption_prev = $monthname[$previous_month-1] . " " . $year;
$table_caption = $monthname[date("n",$date_string)-1] . " " . $year;
if ($next_month == 13){
$next_month = 1;
$year++;
}
$table_caption_foll = $monthname[$next_month-1] . " " . $year;
if (isset ($_GET['show_event'])){
list ($year, $month, $day) = explode ("-", $_GET['event_date']);
$query = "
SELECT *
FROM " . $event_table . "
WHERE EventYear = '" . $year . "'
AND EventMonth = '" . $month . "'
AND EventDay = '" . $day . "'
ORDER BY EventTime ASC
";
/* connect to the database */
$database_connection = mysql_connect ($server, $username, $password);
mysql_select_db ($database, $database_connection);
$result = mysql_query ($query) or die(mysql_error());
$color_alternated = false;
/* header of the table */
echo "<table width=\"100%\" border=\"" . $table_border . "\" cellpadding=\"" . $table_cellpadding . "\" cellspacing=\"" . $table_cellspacing . "\">";
$date_string = mktime(0,0,0,$month,$day,$year);
$month = sprintf("%01d",$month);
echo "<tr><td align=\"center\" style=\"background-color: #dddddd;color:#333333;font-family:arial, verdana, sans-serif;font-size:15px;font-weight:bold;font-style:normal;\" colspan=\"2\">".$day." " . $monthname[$month-1] . " ".$year."</td></tr>";
while ($record = mysql_fetch_assoc ($result)){
if ($color_alternated){
$color_alternated = true;
$background_color_row = $event_background_color;
}
else{
$color_alternated = true;
$background_color_row = $event_background_color2;
}
echo "<tr class=\"cal_event\">
<td style=\"background-color: #dddddd;color:#333333;border-bottom: 1px solid #333333;font-family:arial, verdana, sans-serif;font-size:10px;font-weight:bold;font-style:normal;\" width=\"1\">" . $record['EventTime'] . "</td>
<td style=\"background-color: #dddddd;color:#333333;border-bottom: 1px solid #333333;font-family:arial, verdana, sans-serif;font-size:10px;font-weight:normal;font-style:normal;\">" . nl2br($record['Event']) . "</td>
</tr>";
}
echo "</table>";
/* bring an exit so the script will terminate*/
exit;
}
echo "
<script language=\"javascript\">
function open_event(date_stamp){
window.open(\"" . $calendar_script . "?show_event=true&event_date=\" + date_stamp, \"calendar_popup\",\"height=" . $event_popup_height . ",width=".$event_popup_width."\");
}
</script>
<table border=\"" . $table_border . "\" cellpadding=\"" . $table_cellpadding . "\" cellspacing=\"" . $table_cellspacing . "\" style=\"height:" . $table_height . "\" width=\"" . $table_width . "\">
<tr>
<td align=\"center\" class=\"cal_head\"><a class=\"cal_head\" href=\"" . $_SERVER['PHP_SELF'] . "?" . $QUERY_STRING . "&date=" .
$previous_date . "\" title=\"" . $table_caption_prev . "\">«</a></td>
<td align=\"center\" class=\"cal_head\" colspan=\"5\">" . $table_caption . "</td>
<td align=\"center\" class=\"cal_head\"><a class=\"cal_head\" href=\"" . $_SERVER['PHP_SELF'] . "?" . $QUERY_STRING . "&date=" .
$next_date . "\" title=\"" . $table_caption_foll . "\">»</a></td>
</tr>
<tr>
<td class=\"cal_days\">".$dayname[0]."</td>
<td class=\"cal_days\">".$dayname[1]."</td>
<td class=\"cal_days\">".$dayname[2]."</td>
<td class=\"cal_days\">".$dayname[3]."</td>
<td class=\"cal_days\">".$dayname[4]."</td>
<td class=\"cal_days\">".$dayname[5]."</td>
<td class=\"cal_days\">".$dayname[6]."</td>
</tr><tr>
";
for( $i = 0 ; $i < $day_start; $i++ )
{
echo "<td class=\"cal_content\"> </td>";
}
$current_position = $day_start;
$total_days_in_month = date("t",$date_string);
if ($events_from_database)
{
$database_connection = mysql_connect ($server, $username, $password);
mysql_select_db ($database, $database_connection);
$result = mysql_query("
SELECT *
FROM " . $event_table . "
WHERE
EventYear = '" . $year . "'
AND
EventMonth = '" . $month . "'
");
while ($record = mysql_fetch_assoc($result)){
$event[$record['EventDay']] = $record;
}
}
for( $i = 1; $i <= $total_days_in_month ; $i++)
{
$class = "cal_content";
if( $i == date("j") && $month == date("n") && $year == date("Y") )
$class = "cal_today";
$current_position++;
$link_start = "";
$link_end = "";
if( isset($event[$i]) )
{
$link_start = "<a href=\"java script:;\" class=\"cal_event\" onclick=\"java script: open_event('".$year."-".$month."-".$i."');\">";
$link_end = "</a>";
$class = "cal_event";
}
$date_stamp = $year."-".$month."-".sprintf( "%02d",$i);
echo "<td align=\"center\" class=\"" . $class . "\">" . $link_start . $i . $link_end . "</td>";
if( $current_position == 7 )
{
echo "</tr><tr>\n";
$current_position = 0;
}
}
$end_day = 7-$current_position;
for( $i = 0 ; $i < $end_day ; $i++ )
echo "<td class=\"cal_content\"></td>\n";
echo "</tr></table>";
?>
---------------------PHP SLUT
//Carsten
