Hier ein Beispiel auf meiner Tutorials-Seite:
https://www.mobirise-tutorials.com/Tuto ... lender.php
P.S.:
mir fällt da gerade noch etwas auf.
Der kleine Kalender zeigt am 01.01.2023 einen Montag an - das ist aber ein Sonntag

PHP hat geschrieben:
N ISO 8601 numeric representation of the day of the week 1 (for Monday) through 7 (for Sunday)
w Numeric representation of the day of the week 0 (for Sunday) through 6 (for Saturday)
Code: Alles auswählen
https://www.mobirise-tutorials.com/Tutorials/Kalender.php?month=1&year=2023#Kalender
Code: Alles auswählen
<!-- Kalender -->
<?php
$date = date_create("now", timezone_open("Europe/Berlin"));
$month = $_GET["month"] ?? date_format($date, "n");
$month = (($month < 1) ? 12 : (($month > 12) ? 1 : $month));
$year = $_GET["year"] ?? date_format($date, "Y");
$elected = date_create($year . "-" . $month . "-01 00:00:00", timezone_open("Europe/Berlin"));
$columns = [];
$months = [1 => "Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"];
$weekdays = ["Mo", "Di", "Mi", "Do", "Fr", "Sa", "So"];
echo '<table>
<tr>
<th colspan="4">
<a href="?month=' . ($month - 1) . '&year=' . $year . '#Kalender" class="kal">-</a>
' . $months[date_format($elected, "n")] . '
<a href="?month=' . ($month + 1) . '&year=' . $year . '#Kalender" class="kal">+</a>
</th>
<th colspan="3">
<a href="?month=' . $month . '&year=' . ($year - 1) . '#Kalender" class="kal">-</a>
' . date_format($elected, "Y") . '
<a href="?month=' . $month . '&year=' . ($year + 1) . '#Kalender" class="kal">+</a>
</th></tr>' .
'<tr><th>' . implode('</th><th>', $weekdays) . '</th></tr>';
for ($i = 1; $i < date_format(date_modify(clone $elected, 'first day of this month'), "N"); $i++) {
$columns[] = "";
}
for ($days = 1; $days <= date_format($elected, "t"); $days++) {
$columns[] = ((
($days == date_format($date, "j")) &&
($month == date_format($date, "n")) &&
($year == date_format($date, "Y"))) ? '<mark>' . $days . '</mark>' : $days);
}
foreach ($columns as $i => $column) {
echo '<td>' . $column . '</td>' . ((($i + 1) % 7) ? '' : '</tr><tr>');
}
echo '</tr></table>';
?>
Code: Alles auswählen
Uncaught TypeError: URL constructor: ?month=1&year=2024#Kalender is not a valid URL.
H https://www.mobirise-tutorials.com/Tutorials/assets/smart-cart/minicart-customizer.js:13
Code: Alles auswählen
document.addEventListener("click", function(a) {
var b = a.target.getAttribute("href");
if (b) {
var e = new URL(b),
Code: Alles auswählen
<!-- Kalender -->
<table>
<tr>
<th colspan="4">
<a href="?month=0&year=2022#Kalender" class="kal">-</a>
Januar
<a href="?month=2&year=2022#Kalender" class="kal">+</a>
</th>
<th colspan="3">
<a href="?month=1&year=2021#Kalender" class="kal">-</a>
2022
<a href="?month=1&year=2023#Kalender" class="kal">+</a>
Code: Alles auswählen
<a href="Kalender.php#Kalender">Kalender</a>
Code: Alles auswählen
<!-- Kalender -->
<table>
<tr>
<th colspan="4">
<a href="Kalender.php?month=11&year=2022#Kalender" class="kal">-</a>
Dezember
<a href="Kalender.php?month=13&year=2022#Kalender" class="kal">+</a>
</th>
<th colspan="3">
<a href="Kalender.php?month=12&year=2021#Kalender" class="kal">-</a>
2022
<a href="Kalender.php?month=12&year=2023#Kalender" class="kal">+</a>
Code: Alles auswählen
<!-- Kalender -->
<table>
<tr>
<th colspan="4">
<a href="https://www.mobirise-tutorials.com/Testseiten/Test/Test-Tutorials/Kalender.php?month=11&year=2022#Kalender" class="kal">-</a>
Dezember
<a href="https://www.mobirise-tutorials.com/Testseiten/Test/Test-Tutorials/Kalender.php?month=13&year=2022#Kalender" class="kal">+</a>
</th>
<th colspan="3">
<a href="https://www.mobirise-tutorials.com/Testseiten/Test/Test-Tutorials/Kalender.php?month=12&year=2021#Kalender" class="kal">-</a>
2022
<a href="https://www.mobirise-tutorials.com/Testseiten/Test/Test-Tutorials/Kalender.php?month=12&year=2023#Kalender" class="kal">+</a>
Code: Alles auswählen
<!-- Reload für Gästebuchseiten -->
<script>
function myPage(seite) {
window.location.href = 'Gastbuch.php?seite=' + seite + '#content1-aw';
}
</script>
Code: Alles auswählen
// Navigation Zurück /Weiter
if ($AnzahlDatensaetze > $EINTRAEGE_SEITE) {
print '<p>' . (($AktuelleSeite - 1) > 0 ? '<a href="?seite=' . ($AktuelleSeite - 1) . '#content1-aw" onclick="myPage(\'' . ($AktuelleSeite - 1) . '\')">◄ Zurück</a> ' : '') . ' ' .
(($AktuelleSeite + 1) <= $Seitenanzahl ? '<a href="?seite=' . ($AktuelleSeite + 1) . '#content1-aw" onclick="myPage(\'' . ($AktuelleSeite + 1) . '\')">Weiter ►</a>' : '') . '</p>';
}
Code: Alles auswählen
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
</head>
<body>
<a href="?month=1&year=2023#abc">A</a>
- -
<a href="?month=3&year=2023#abc">B</a>
<script src="assets/smart-cart/minicart.js"></script>
<script src="assets/smart-cart/minicart-customizer.js"></script>
</body>
</html>
What's new:
* Fix for anchors
Mitglieder in diesem Forum: 0 Mitglieder und 1 Gast