20. januar 2009 - 22:16Der er
11 kommentarer og 1 løsning
Kalender system, virker allerede
Hej xperter
Jeg har fundet et kalender system som virker fint og kan sættes op til at køre på en MySql DB, hvilket jeg lokalt har gjort.
Det virker fint og alt er peachy..... eller næsten.
Mit problem er at når jeg har lavet en entry i min DB som f.eks gælder den 10. feb, så går jeg ind på kalenderen i frontend og ser hvordan det spiller der.
Når jeg klikker på den pågældende dato (10. feb) så åbnes der et pop-up vindue hvor min entry står, men tabel headeren står der den 10. marts og ikke den 10. feb, som der skulle.
Kan simpelthen ikke finde ud af hvorfor den tæller forkert, og håber en af jer kan hjælpe mig lidt hurtigt.
Jeg kan sagtens smide noget kode hvis det er nødvendigt ellers smider jeg lige et download link i alle tilfælde. Download her: http://www.my-php.tk/ >>>> Scripts >>>>> CalendarV2.0 og et virkende eksempel (dog uden DB tilknyttet): http://www.pcdummy.nl/~myphp/script/example/6
Jeg smider lige noget kode her og nede i koden har jeg sat nogle heftige markeringer hvor jeg tror der opstår et eller andet mismatch:
Kode (dette er al koden): // $calendar_script = "calendar2.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 = "#000000"; //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 = "250"; //Width of the popup for the events $event_popup_height = "350"; //Height of the popup for the events
$head_background_color = "#DDDDDD"; //Background color of the column $head_font_color = "green"; //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 = "gray"; //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 = "green"; //The color of the link for previous/next month
$font_family = "Verdana";
/* 17 June 2004 : Check readme.txt for MySQL code for the database table */
$events_from_database = true; //Set to true if you want to retrieve events $database = "caltest"; //Name of the database within the event_table $server = "localhost"; //Name of the server $username = "******"; //MySQL username $password = "*******"; //MySQL password $event_table = "calendar_events"; //Name of the calendar_events //
/////////////////////////////////////////////
///////////////////////////////////////////// //Load the language into usable variables //
//darussol: TRANSLATION (18 May 2004) // : Fill in the names of the days/months in variables //e-man : LOAD TRANSLATION FILE INTO VARIABLES (from darussol)(19 May 2004) // : Put the days/months names from language file into a array
$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 // /////////////////////////////////////////////
///////////////////////////////////////////// //Use the date to build up the calendar. From the Query_string or the current date // 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); //The date string we need for some info... saves space ^_^
$day_start = date("w",$date_string); //The number of the 1st day of the week
///////////////////////////////////////////// //Filter the current $_GET['date'] from the QUERY_STRING // $QUERY_STRING = ereg_replace("&date=".$month."-".$year,"",$_SERVER['QUERY_STRING']); // /////////////////////////////////////////////
// darussol: DEFINITION OF THETRANSLATED MONTH+YEAR TO BE USED IN THE TABLE AND INFO-TITLES (18 May 2004) // e-man : USING THE VALUES OF THE PREVIOUS AND NEXT MONTH FOR THE TITLE DAY (19 May 2004); $table_caption_prev = $monthname[$previous_month-1] . " " . $year; // previous $table_caption = $monthname[date("n",$date_string)-1] . " " . $year; // current if ($next_month == 13){ $next_month = 1; $year++; } $table_caption_foll = $monthname[$next_month-1] . " " . $year; // following
///////////////////////////////////////////// //The empty columns before the 1st day of the week // for( $i = 0 ; $i < $day_start; $i++ ) { echo "<td class=\"cal_content\"> </td>"; } // /////////////////////////////////////////////
$current_position = $day_start; //The current (column) position of the current day from the loop
$total_days_in_month = date("t",$date_string); //The total days in the month for the end of the loop
///////////////////////////////////////////// //Retrieve events for the current month + year //e-man : added 07 June 04 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; } } // /////////////////////////////////////////////
///////////////////////////////////////////// //Loop all the days from the month // for( $i = 1; $i <= $total_days_in_month ; $i++) { $class = "cal_content";
HTML koden her er sakset fra netop pop-up vinduet og det output der kommer er her fra den datoen den 11. marts, men der står følgende i headeren: <tr> <td class="cal_head" align="center" colspan="2">11 April 2009</td> </tr>
For de der efterfølgende læser denne post, kommer her en omgang php kode til at inserte entries i kalenderen, som dog kun er testet lokalt så jeg vil ikke lægge hovedet på blokken og garantere at det virker uden på en webserver, men måske kan det hjælpe nogen alligevel.
KODE: <?
if (isset($_POST["submit"])){
echo "<span class=\"broed\">Nyheden er tilføjet</span>"; require_once "fil_forbind_til_mysql.php";
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.