First of all, big thanks!
Second, you seem to be a way better programmer than I am. To be honest, I can’t make head nor tail of your code. Do I need anything else to run it?
I am not using any database wrappers (if this is what you are using).
A “ready made” snippet would be very welcome of course. But most I was interested in the “correct and most efficient” way to do it.
Here is my code so far (database part not included yet). I took a snippet from the source still mentioned in the code and changed it around a bit.
It should run “out of the box”:
[php]
<?php
// https://css-tricks.com/snippets/php/build-a-calendar-table/
$dstart = 1444867200;
$dend = 1445904000;
$this_month = mktime();
//echo mktime(0,0,0,8,1,2015) - mktime(0,0,0,7,1,2015) . "
";
for ($ml=0;$ml<12;$ml++)
{
$dateComponents = getdate($this_month);
$month = $dateComponents['mon'];
$year = $dateComponents['year'];
echo "
";
echo build_calendar($month,$year,$dateArray,$dstart,$dend);
//echo $this_month . "
" . $mon . " / " . $year;
echo "
";
$this_month = $this_month + 2678400;
}
//echo build_calendar($month,$year,$dateArray,$dstart,$dend);
function build_calendar($month,$year,$dateArray,$dstart,$dend) {
// Create array containing abbreviations of days of week.
$daysOfWeek = array('Mo','Di','Mi','Do','Fr','Sa','So');
// Create array containing monthnames in German.
$monthsOfYear = array('','Januar','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember');
// What is the first day of the month in question?
$firstDayOfMonth = mktime(0,0,0,$month,1,$year);
// How many days does this month contain?
$numberDays = date('t',$firstDayOfMonth);
// Retrieve some information about the first day of the
// month in question.
$dateComponents = getdate($firstDayOfMonth);
// What is the name of the month in question?
$monthNumber = $dateComponents['mon'];
//echo "monthNumber: " . $monthNumber;
$monthName = $monthsOfYear[$monthNumber];
// What is the index value (0-6) of the first day of the
// month in question.
$dayOfWeek = $dateComponents['wday'];
// Create the table tag opener and day headers
$calendar = "
";
$calendar .= "$monthName $year";
$calendar .= "";
// Create the calendar headers
foreach($daysOfWeek as $day) {
$calendar .= "$day | ";
}
// Create the rest of the calendar
// Initiate the day counter, starting with the 1st.
$currentDay = 1;
$calendar .= "
";
// The variable $dayOfWeek is used to
// ensure that the calendar
// display consists of exactly 7 columns.
if ($dayOfWeek > 0) {
$dayOfWeek--;
$calendar .= " | ";
}
$month = str_pad($month, 2, "0", STR_PAD_LEFT);
while ($currentDay <= $numberDays) {
// Seventh column (Saturday) reached. Start a new row.
if ($dayOfWeek == 7) {
$dayOfWeek = 0;
$calendar .= "
";
}
$currentDayRel = str_pad($currentDay, 2, "0", STR_PAD_LEFT);
$date = "$year-$month-$currentDayRel";
$calendar .= "" . $tday . $tmonth . $tyear . " " . $this_day . " " . $dstart . "->" . $this_day . "<-" . $dend . " | ";
$calendar .= "' rel='$date'>" . $currentDay . "";
// Increment counters
$currentDay++;
$dayOfWeek++;
}
// Complete the row of the last week in month, if necessary
if ($dayOfWeek != 7) {
$remainingDays = 7 - $dayOfWeek;
$calendar .= " | ";
}
$calendar .= "
";
$calendar .= "
";
return $calendar;
}
?>
[/php]
Code for a grid layout will also be added later, this is jut for testing purposes.
Does your script still apply to it and how would I get it to run?
Big thanks again!
Edit: Just noticed your signature about PDO. Will check it out now 
2nd Edit: PDO extension was already enabled
When I run your code, the first statement already gives an error:
Parse error: syntax error, unexpected T_PROTECTED in C:\wamp\www\drittehand\phphelp.php on line 4
I removed the “protected” and the next thing it gives me is:
Parse error: syntax error, unexpected '[', expecting ')' in C:\wamp\www\drittehand\phphelp.php on line 16
which is:
[php]$this->stmt->execute([’:date’ => $this->urlDate, ‘:created_by’ => $this->username]);[/php]
Sorry to be such a pain, but as I said, your code is a bit above me …
btw., I am running PHP 5.3.13 and MySQL 5.5.24 on Wampserver