hallo zusammen,
habe mir aus dem internet einen php kalender heruntergeladen und ihn in meine seite integriert. dieser hat auch die funktion events aus einer mysql datenbank herauszulesen und die tage an denen ein event stattfindet werden zum link und man kann draufklicken und ein popup öffnet sich. ich hätte jetzt aber gerne, dass an den tagen an denen etwas stattfindet mir neben dem datum auch das event ausgegeben wird.
mit dem hier:
PHP-Code:
echo "<td align=\"right\" valign=\"top\" class=\"" . $class . "\">" . $link_start . $i. $link_end . "</td>";
wird der tag an dem ein event ist ausgegeben und ich möchte gerne das $record['verein'] hinzufügen, weis aber nicht genau wie?
so passiert gar nichts:
PHP-Code:
echo "<td align=\"right\" valign=\"top\" class=\"" . $class . "\">" . $link_start . $i.$record['verein']. $link_end . "</td>";
PHP-Code:
<div id="kalender_gr">
<?php
/******************************************************
Calender 2.22
Written by Erik Holman at 6 May 2004
Started at 16:00 and ended at 17:00
CHANGES by Daniele Russolillo, 18 May 2004
+ variables for CSS definition of week days
+ variables for easy translation of week days and months
+ infotitles for previous/following URLS on the calendar
Personal homepage at [url]http://daniele.nkoni.org[/url] If you like
the changes have a look at [url]http://www.nkoni.org/[/url] and
pass it on to help 500 Ugandan AIDS Orphans.
CHANGES by Erik Holman, 19 May 2004
+ variables for the language file.
+ added possibility to load language files
CHANGES by Erik Holman, 17 June 2004
+ Added possibility to load events from MySQL database
BUG SOLVED by Erik Holman, 24 June 2004
- Instead of loading one event, all the events will be shown now.
To look for from Erik Holman changes just FIND e-man within this script...
To look for from darussol changes just FIND darussol within this script...
===================================
This scripts prints a calendar into a table on the
page. You can set some variables to get a differend
layout.
Visit [url]www.my-php.tk[/url] for more free PHP scripts.
******************************************************/
/////////////////////////////////////////////
//Declare some variables
//
$calendar_script = "_calendar_gr.inc.php"; //The location of this script
$calendar_language = "ger"; //The extension of the calendar language file.
$content_background_color_gr = "#fff"; //Background color of the column
$content_font_color_gr = "#333"; //The font color
$content_font_size_gr = 11; //Font-size in pixels
$content_font_style_gr = "normal"; //Set to italic or normal
$content_font_weight_gr = "normal"; //Set to bold or normal
$today_background_color_gr = "#a4bd28"; //Background color of the column
$today_font_color_gr = "#fff"; //The font color
$today_font_size_gr = 11; //Font-size in pixels
$today_font_style_gr = "normal"; //Set to italic or normal
$today_font_weight_gr = "bold"; //Set to bold or normal
$event_background_color_gr = "#d0dd99"; //Background color of the column
$event_background_color2_gr = "#f3f8e9"; //Background color of the 2nd column (event popup)
$event_font_color_gr = "#000000"; //The font color
$event_font_size_gr = 10; //Font-size in pixels
$event_font_style_gr = "normal"; //Set to italic or normal
$event_font_weight_gr = "lighter"; //Set to bold or normal
$event_popup_width_gr = "203"; //Width of the popup for the events
$event_popup_height_gr = "350"; //Height of the popup for the events
$head_background_color_gr = "#d0dd99"; //Background color of the column
$head_font_color_gr = "#fff"; //The font color
$head_font_size_gr = 11; //Font-size in pixels
$head_font_style_gr = "normal"; //Set to italic or normal
$head_font_weight_gr = "bold"; //Set to bold or normal
//darussol: CSS OPTIONS FOR WEEK DAYS
$days_head_background_color_gr = "#a4bd28"; //Background color of the column
$days_head_font_color_gr = "#666"; //The font color
$days_head_font_size_gr = 11; //Font-size in pixels
$days_head_font_style_gr = "normal"; //Set to italic or normal
$days_head_font_weight_gr = "bold"; //Set to bold or normal
$table_border_gr = 0; //The border of the table
$table_cellspacing_gr = 0; //Cellspacing of the table
$table_cellpadding_gr = 5; //Cellpadding of the table
$table_width_gr = ''; //Table width in pixels or %'s
$table_height_gr = ''; //Table height in pixels or %'s
$head_link_color_gr = "#666"; //The color of the link for previous/next month
$font_family_gr = "Arial";
/* 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 = ""; //Name of the database within the event_table
$server = "localhost"; //Name of the server
$username = ""; //MySQL username
$password = ""; //MySQL password
$event_table = ""; //Name of the calendar_events*/
//local zum testen
$database = ""; //Name of the database within the event_table
$server = ""; //Name of the server
$username = ""; //MySQL username
$password = ""; //MySQL password
$event_table = ""; //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']);
//
/////////////////////////////////////////////
/////////////////////////////////////////////
//Calculate the previous/next month/year
//
if ($month == 1)
{
$next_month = 2;
$next_date = "2-".$year;
$previous_month = 12;
$previous_year = $year-1;
$previous_date = "12-".$previous_year;
}
elseif ($month == 12)
{
$next_month = 1;
$next_year = $year+1;
$next_date = "1-".$next_year;
$previous_month = 11;
$previous_date = "11-".$year;
}
else
{
$next_month = $month+1;
$next_date = $next_month."-".$year;
$previous_month = $month-1;
$previous_date = $previous_month."-".$year;
}
//
/////////////////////////////////////////////
// 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
/////////////////////////////////////////////
//Print the calendar css code
//
echo "
<style type=\"text/css\">
body{
margin:0;
}
a.cal_head_gr
{
color: " . $head_link_color_gr . ";
}
a.cal_head_gr:hover
{
text-decoration: none;
}
.cal_head_gr
{
background-color: " . $head_background_color_gr . ";
color: " . $head_font_color_gr . ";
font-family: " . $font_family_gr . ";
font-size: " . $head_font_size_gr . ";
font-weight: " . $head_font_weight_gr . ";
font-style: " . $head_font_style_gr . ";
height:23px;
}
.cal_days_gr /*darussol*/
{
background-color: " . $days_head_background_color_gr . ";
color: " . $days_head_font_color_gr . ";
font-family: " . $font_family_gr . ";
font-size: " . $days_head_font_size_gr . ";
font-weight: " . $days_head_font_weight_gr . ";
font-style: " . $days_head_font_style_gr . ";
text-align:center;
}
.cal_content_gr
{
background-color: " . $content_background_color_gr . ";
color: " . $content_font_color_gr . ";
font-family: " . $font_family_gr . ";
font-size: " . $content_font_size_gr . ";
font-weight: " . $content_font_weight_gr . ";
font-style: " . $content_font_style_gr . ";
height: 112px;
border-bottom:1px dotted #a4bd28;
border-left:1px dotted #a4bd28;
}
.cal_today_gr
{
background-color: " . $today_background_color_gr . ";
color: " . $today_font_color_gr . ";
font-family: " . $font_family_gr . ";
font-size: " . $today_font_size_gr . ";
font-weight: " . $today_font_weight_gr . ";
font-style: " . $today_font_style_gr . ";
}
.cal_event_gr, a.cal_event_gr /* e-man 17-06-04 */
{
background-color: " . $event_background_color_gr . ";
color: " . $event_font_color_gr . ";
font-family: " . $font_family_gr . ";
font-size: " . $event_font_size_gr . ";
font-weight: " . $event_font_weight_gr . ";
font-style: " . $event_font_style_gr . ";
}
.title_popup_gr{
height:20px;
width:193px;
}
#popup_title_gr{
background-image:url(images/top_bar.gif);
background-position:right top;
background-repeat:repeat-x;
width:193px;
height:19px;
padding-left:10px;
padding-top:6px;
color:#fff;
font-weight:bold;
font-size:12px;
font-family:Arial, Helvetica, sans-serif;
}
</style>
";
//
/////////////////////////////////////////////
/////////////////////////////////////////////
//show events in popup?
//
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());
/* initize the variabele color_alternated (boolean) */
$color_alternated = false;
/* header of the table */
echo "<table width=\"100%\" border=\"" . $table_border_gr . "\" cellpadding=\"" . $table_cellpadding_gr . "\" cellspacing=\"" . $table_cellspacing_gr . "\">";
$date_string = mktime(0,0,0,$month,$day,$year);
$month = sprintf("%01d",$month);
echo "<tr><td align=\"center\" class=\"cal_head_gr\" colspan=\"2\">".$day.".".$month.".".$year."</td></tr>";
/* loop through the results via a mysql_fetch_assoc () */
while ($record = mysql_fetch_assoc ($result)){
if ($color_alternated){
$color_alternated = false;
$background_color_row = $event_background_color_gr;
}
else{
$color_alternated = true;
$background_color_row = $event_background_color2_gr;
}
echo "<tr class=\"cal_event_gr\">
<td style=\"background-color:".$background_color_row."\">
" . $record['EventTime'] . " - " . nl2br($record['titel']) . "</p>
" . nl2br($record['untertitel']) . "</p>
" . nl2br($record['verein']) . " - " . nl2br($record['thema']) . "</p>
" . nl2br($record['Event']) . "</p>
</td>
</tr>";
}
/* close the table */
echo "</table>";
/* bring an exit so the script will terminate*/
exit;
}
//
/////////////////////////////////////////////
/////////////////////////////////////////////
//Print the calendar table header
//
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_gr . ",width=".$event_popup_width_gr.",scrollbars=yes\");
}
</script>
<table border=\"" . $table_border_gr . "\" cellpadding=\"" . $table_cellpadding_gr . "\" cellspacing=\"" . $table_cellspacing_gr . "\" style=\"height:" . $table_height_gr . "\" width=\"" . $table_width_gr . "\">
<tr>
<td align=\"center\" class=\"cal_head_gr\"><a class=\"cal_head_gr\" href=\"" . $_SERVER['PHP_SELF'] . "?" . $QUERY_STRING . "&date=" .
$previous_date . "\" title=\"" . $table_caption_prev . "\">«</a></td>
<td align=\"center\" class=\"cal_head_gr\" colspan=\"5\">" . $table_caption . "</td>
<td align=\"center\" class=\"cal_head_gr\"><a class=\"cal_head_gr\" href=\"" . $_SERVER['PHP_SELF'] . "?" . $QUERY_STRING . "&date=" .
$next_date . "\" title=\"" . $table_caption_foll . "\">»</a></td>
</tr>
<tr>
<td class=\"cal_days_gr\">".$dayname[0]."</td>
<td class=\"cal_days_gr\">".$dayname[1]."</td>
<td class=\"cal_days_gr\">".$dayname[2]."</td>
<td class=\"cal_days_gr\">".$dayname[3]."</td>
<td class=\"cal_days_gr\">".$dayname[4]."</td>
<td class=\"cal_days_gr\">".$dayname[5]."</td>
<td class=\"cal_days_gr\">".$dayname[6]."</td>
</tr><tr>
";
//
/////////////////////////////////////////////
/////////////////////////////////////////////
//The empty columns before the 1st day of the week
//
for( $i = 0 ; $i < $day_start; $i++ )
{
echo "<td class=\"cal_content_gr\"></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_gr";
if( $i == date("j") && $month == date("n") && $year == date("Y") )
$class = "cal_today_gr";
$current_position++;
/* is there any event on this day? Yes, create a link. No clear the (previous) string */
$link_start = "";
$link_end = "";
/* if there is an event do */
if( isset($event[$i]) )
{
$link_start = "<a href=\"javascript:;\" class=\"cal_event_gr\" onclick=\"javascript: open_event('".$year."-".$month."-".$i."');\">";
$link_end = "</a>";
$class = "cal_event_gr";
}
/* for the event filter */
/* e-man : added 07 June 04 */
$date_stamp = $year."-".$month."-".sprintf( "%02d",$i);
echo "<td align=\"right\" valign=\"top\" class=\"" . $class . "\">" . $link_start . $i. $link_end . "</td>";
if( $current_position == 7 )
{
echo "</tr><tr>\n";
$current_position = 0;
}
}
//
/////////////////////////////////////////////
$end_day = 7-$current_position; //There are
/////////////////////////////////////////////
//Fill the last columns
//
if($end_day<7){
for( $i = 0 ; $i < $end_day ; $i++ )
echo "<td class=\"cal_content_gr\"></td>\n";
}
//Fill the last columns
//
//
/////////////////////////////////////////////
echo "</tr></table>"; // Close the table
?>
</div>