diff --git a/statistics/functions.php b/statistics/functions.php index c411062..8ae523d 100644 --- a/statistics/functions.php +++ b/statistics/functions.php @@ -127,3 +127,10 @@ function get_series_verlauf($arrData,$arrBezeichnung){ return $strResult; } +function titleYears(int $numLatestYear, int $numStartYear) { + $html = ""; + for ($year = $numLatestYear; $year >= $numStartYear; $year--) { + $html .= "{$year}"; + } + return $html; +} \ No newline at end of file diff --git a/statistics/gemeinde_details.php b/statistics/gemeinde_details.php index 868cee0..3256a28 100644 --- a/statistics/gemeinde_details.php +++ b/statistics/gemeinde_details.php @@ -63,7 +63,7 @@

Unfallverlauf von bis

- + diff --git a/statistics/gemeinden.php b/statistics/gemeinden.php index 28b691d..fc4922b 100644 --- a/statistics/gemeinden.php +++ b/statistics/gemeinden.php @@ -26,82 +26,83 @@ - + = $bis; $y--) { + $class = ($y == $von && $mitRand) ? " class='l'" : ""; + $html .= "{$y}"; + } + return $html; +} +function jahresSpaltenSQL($prefix, $von, $bis, $bedingung = "") { + $cols = []; + for ($y = $von; $y >= $bis; $y--) { + $cond = $bedingung ? " AND {$bedingung}" : ""; + $cols[] = "SUM(UJAHR={$y}{$cond}) as {$prefix}_{$y}"; + } + return implode(",\n ", $cols); +} +function jahresZellen($row, $prefix, $von, $bis) { + $html = ""; + for ($y = $von; $y >= $bis; $y--) { + $class = ($y == $von) ? " class='l'" : ""; + $html .= "" . $row["{$prefix}_{$y}"] . ""; + } + return $html; +} + + ?> + -
+

Fahrradunfälle in Nordrhein-Westfalen in Gemeinden

2025202420232022202120202019
- - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + +query($strSQL); @@ -109,39 +110,16 @@ $result=$db->query($strSQL); while ($row = $result->fetch(PDO::FETCH_ASSOC)) { echo ""; echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; + echo jahresZellen($row, 'Jahr', $numLatestYear, $numStartYear); + echo jahresZellen($row, 'Tode', $numLatestYear, $numStartYear); + echo jahresZellen($row, 'Schwerverletzt', $numLatestYear, $numStartYear); + echo jahresZellen($row, 'Leichtverletzt', $numLatestYear, $numStartYear); echo ""; echo ""; - echo ""; + echo ""; echo "\n"; } + ?>
FahrradunfälleTodesfälleSchwerverletzteLeichtverletzteFächeEinw.Quote
Name2025202420232022202120202019202520242023202220212020201920252024202320222021202020192025202420232022202120202019in Tausend
FahrradunfälleTodesfälleSchwerverletzteLeichtverletzteFlächeEinw.Quote
Namein Tausend
".$row['Gemeinde']."".$row['Jahr_2025']."".$row['Jahr_2024']."".$row['Jahr_2023']."".$row['Jahr_2022']."".$row['Jahr_2021']."".$row['Jahr_2020']."".$row['Jahr_2019']."".$row['Tode_2025']."".$row['Tode_2024']."".$row['Tode_2023']."".$row['Tode_2022']."".$row['Tode_2021']."".$row['Tode_2020']."".$row['Tode_2019']."".$row['Schwerverletzt_2025']."".$row['Schwerverletzt_2024']."".$row['Schwerverletzt_2023']."".$row['Schwerverletzt_2022']."".$row['Schwerverletzt_2021']."".$row['Schwerverletzt_2020']."".$row['Schwerverletzt_2019']."".$row['Leichtverletzt_2025']."".$row['Leichtverletzt_2024']."".$row['Leichtverletzt_2023']."".$row['Leichtverletzt_2022']."".$row['Leichtverletzt_2021']."".$row['Leichtverletzt_2020']."".$row['Leichtverletzt_2019']."".$row['Flaeche']."".round($row['Einwohner']/1000,1)."".round($row['Quote_2025'],2)."".round($row["Quote_{$numLatestYear}"],2)."
diff --git a/statistics/kreis_details.php b/statistics/kreis_details.php index 1cb3bf9..306affe 100644 --- a/statistics/kreis_details.php +++ b/statistics/kreis_details.php @@ -2,6 +2,7 @@ require_once("../config.php"); require_once("../lib/attributes.php"); require_once("functions.php"); + $numLand=5; // NRW $numRegbez=(isset($_GET['regbez'])) ? (int)$_GET['regbez'] : 1; $numKreis=(isset($_GET['kreis'])) ? (int)$_GET['kreis'] : 1; @@ -68,7 +69,7 @@

Unfallverlauf von bis

- + diff --git a/statistics/nrw_details.php b/statistics/nrw_details.php index bb7636c..23f9835 100644 --- a/statistics/nrw_details.php +++ b/statistics/nrw_details.php @@ -55,7 +55,7 @@

Unfallverlauf von bis

2025202420232022202120202019
- +
2025202420232022202120202019