Hallo Leute,
ich bin PHP neewbie und hätte da ne frage.
Ich habe ein php script geschrieben für ein Kalender nur jetzt weiß ich nicht wie ich es hinbekommen soll,das er mir die Termine die in einer DB sind im Kalender hervorheben.
Hier der Code:
ich bin PHP neewbie und hätte da ne frage.
Ich habe ein php script geschrieben für ein Kalender nur jetzt weiß ich nicht wie ich es hinbekommen soll,das er mir die Termine die in einer DB sind im Kalender hervorheben.
Hier der Code:
PHP-Code:
<?php
include ("connection.php");
$month = isset($_GET['month']) ? intval($_GET['month']) : date('n');
$year = isset($_GET['year']) ? intval($_GET['year']) : date('Y');
$options['today_class'] = "background-color:#FFFF00; font-weight:bold; color:#5F98B5;";
$optionsurlaub['today_class'] = "background-color:#40FF00; font-weight:bold; color:#000000;";
$weekdays = array('So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa');
$months = array('01' => 'Januar', '02' => 'Februar', '03' => 'Mauml;rz', '04' => 'April', '05' => 'Mai', '06' => 'Juni', '07' => 'Juli', '08' => 'August', '09' => 'September', '10' => 'Oktober', '11' => 'November', '12' => 'Dezember');
$prev_symbol = "«";
$next_symbol = "»";
$summary = "Mein erster Kalender";
$caption = "Kalender";
$options['month_link'] = '<a href="'.$_SERVER['PHP_SELF'].'?month=%d&year=%d">%s</a>';
$total_days = date('t', mktime(0, 0, 0, $month, 1, $year));
$day_offset = date('w', mktime(0, 0, 0, $month, 1, $year));
list($n_month, $n_year, $n_day) = split(', ', strftime('%m, %Y, %d'));
$day_highlight = (($n_month == $month) && ($n_year == $year));
list($n_prev_month, $n_prev_year) = split(', ', strftime('%m, %Y', mktime(0, 0, 0, $month-1, 1, $year)));
$prev_month_link = sprintf($options['month_link'], $n_prev_month, $n_prev_year, $prev_symbol);
list($n_next_month, $n_next_year) = split(', ', strftime('%m, %Y', mktime(0, 0, 0, $month+1, 1, $year)));
$next_month_link = sprintf($options['month_link'], $n_next_month, $n_next_year, $next_symbol);
echo '
<table border="0" summary="'.$summary.'">
<caption>'.$caption.'</caption>
<thead>
<tr>
<th>'.$prev_month_link.'</th>
<th colspan="5">'.$months[strftime('%m', mktime(0, 0, 0, $month, 1, $year))].' '.$year.'</th>
<th>'.$next_month_link.'</th>
</tr>';
echo "<tr>\n";
foreach ($weekdays as $weekday)
{
echo "\t";
echo "<th>".$weekday."</th>\n";
echo "\n";
}
echo "\n";
echo "\n";
echo "</tr>
</thead>
<tbody>\n";
echo "<tr>\n";
if ($day_offset > 0) {
for ($i=0; $i<$day_offset; $i++)
{
echo "\t";
echo '<td class="empty_cell">';
echo "\n";
}
}
for ($day=1; $day<=$total_days; $day++)
{
if ($day_highlight && ($day == $n_day))
{
echo "\t";
echo '</td>
<td id="day_'.$day.'" style="'.$options['today_class'].'">'.$day.'';
echo "\n";
} else {
echo "\t";
echo '</td>
<td id="day_'.$day.'">'.$day.'</td>';
echo "\n";
}
$day_offset++;
if ($day_offset == 7) {
$day_offset = 0;
if ($day < $total_days)
{
echo "</tr>\n<tr>";
}
}
}
if ($day_offset > 0)
{
$day_offset = 7-$day_offset;
}
if ($day_offset > 0)
{
for ($i=0; $i< $day_offset; $i++)
{
echo '<td class="empty_cell">';
echo "\n";
}
}
echo '</td>
</tr>
</tbody></table>
';
?>

Kommentar