datatable

This commit is contained in:
Walter Hupfeld 2023-10-09 17:52:21 +02:00
parent fddabb11bb
commit d841823661
7 changed files with 376 additions and 238 deletions

View File

@ -1,8 +1,4 @@
<!DOCTYPE html> <!DOCTYPE html>
<?php
require_once("config.php");
$strTitle="Datenschutz";
?>
<html lang="de"> <html lang="de">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
@ -15,7 +11,7 @@
<!-- Navbar --> <!-- Navbar -->
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top"> <nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
<a class="navbar-brand" href="#"><?= $strTitle ?></a> <a class="navbar-brand" href="#">Unfallkarte</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbars" aria-controls="navbars" aria-expanded="false" aria-label="Toggle navigation"> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbars" aria-controls="navbars" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
</button> </button>
@ -28,6 +24,10 @@
<div> <div>
<ul class="navbar-nav mr-auto right"> <ul class="navbar-nav mr-auto right">
<li class="nav-item">
<a class="nav-link" href="statistics/index.php">Statistik</span></a>
</li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="impressum.php">Impressum</a> <a class="nav-link" href="impressum.php">Impressum</a>
</li> </li>

View File

@ -1,9 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="de"> <html lang="de">
<?php
require_once("config.php");
$strTitle="Impressum";
?>
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
@ -15,7 +11,7 @@
<!-- Navbar --> <!-- Navbar -->
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top"> <nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
<a class="navbar-brand" href="#"><?= $strTitle ?></a> <a class="navbar-brand" href="#">Unfallkarte</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbars" aria-controls="navbars" aria-expanded="false" aria-label="Toggle navigation"> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbars" aria-controls="navbars" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
</button> </button>
@ -28,6 +24,9 @@
<div> <div>
<ul class="navbar-nav mr-auto right"> <ul class="navbar-nav mr-auto right">
<li class="nav-item">
<a class="nav-link" href="statistics/index.php">Statistik</span></a>
</li>
<li class="nav-item active"> <li class="nav-item active">
<a class="nav-link" href="impressum.php">Impressum <span class="sr-only">(current)</span></a> <a class="nav-link" href="impressum.php">Impressum <span class="sr-only">(current)</span></a>
@ -57,11 +56,7 @@
<a href="https://www.govdata.de/dl-de/by-2-0" target="_blanc">Datenlizenz Deutschland Namensnennung Version 2.0</a></p> <a href="https://www.govdata.de/dl-de/by-2-0" target="_blanc">Datenlizenz Deutschland Namensnennung Version 2.0</a></p>
<p>&nbsp;</p> <p>&nbsp;</p>
<h3>Weitere Auswertungen zu Fahrradunfällen</h3>
<ul>
<li><a href="statistics/">Fahrradunfälle nach Kreisen und kreisfreien Städten</a></li>
<li><a href="statistics/gemeinden.php">Fahrradunfälle nach Gemeinden</a></li>
</ul>
<p>&nbsp;</p> <p>&nbsp;</p>
<h3>Impressum</h3> <h3>Impressum</h3>

120
index.php
View File

@ -6,126 +6,11 @@
$numYear=$numLatestYear; $numYear=$numLatestYear;
$strDistrict = (isset($_GET['d'])) ? $_GET['d'] : "Hamm"; $strDistrict = (isset($_GET['d'])) ? $_GET['d'] : "Hamm";
$numVehicle = (isset($_GET['v'])) ? (int) $_GET['v'] : 1; $numVehicle = (isset($_GET['v'])) ? (int) $_GET['v'] : 1;
$numYear = (isset($_GET['year'])) ? (int) $_GET['year'] : $numYear; $numYear = (isset($_GET['year'])) ? (int) $_GET['year'] : $numYear;
require_once("lib/init.php");
$result= $db->prepare("SELECT count(*) FROM district WHERE district=:district");
$result->bindParam(":district",$strDistrict);
$result->execute();
if ($row=$result->fetch(PDO::FETCH_NUM)) {
if ($row[0]==0) $strDistrict="hamm";
}
//$result = $db->query($strSQL);
$result= $db->prepare("SELECT * FROM district WHERE district=:district");
$result->bindParam(":district",$strDistrict);
$result->execute();
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$strDistrict = $row['district'];
$strTitle = $row['title'];
$strGeojson = $row['geojson'];
$numULAND=$row['ULAND'];
$numUREGBEZ=$row['UREGBEZ'];
$numUKREIS=$row['UKREIS'];
$numUGEMEINDE=$row['UGEMEINDE'];
$numInfoLat=$row['lat'];
$numInfoLng=$row['lng'];
$numZoom=$row['zoom'];
$strTitle = "Unfallkarte $strTitle ";
$strIntroText = "$strTitle basierend auf den Daten des Statistischen Bundesamtes.";
$fileGeojson ="geojson/$strGeojson";
$strLocation = " AND ULAND=$numULAND AND UREGBEZ=$numUREGBEZ AND UKREIS=$numUKREIS ";
if ($numUGEMEINDE>0) {
$strLocation .= "AND UGEMEINDE=$numUGEMEINDE";
}
}
$arrDisctrict = array ();
$strSQL = "SELECT district,title FROM district ORDER BY title ASC";
$result=$db->query($strSQL);
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$arrDistrict[$row['district']]=$row['title'];
}
$strIntro ="<h4>".$strTitle."</h4>";
$strIntro .= nl2br2($strIntroText);
switch ($numVehicle) {
case 1:
case 0:
$strWhere ="IstRad = 1";
$topic=2;
break;
case 2:
$strWhere = "IstPKW = 1";
$topic=4;
break;
case 3:
$strWhere = "IstFuss = 1";
$topic=1;
break;
case 4:
$strWhere = "IstKrad = 1";
$topic=0;
break;
case 5:
$strWhere = "IstGkfz = 1";
$topic=5;
break;
case 6:
$strWhere = "IstSonstige = 1";
$topic=3;
break;
default: $strWhere ="IstRad = 1";
$topic=2;
}
$strYear = " AND UJAHR='".$numYear."' ";
$strSQL="SELECT * FROM data WHERE ".$strWhere.$strYear.$strLocation;
$result = $db->query($strSQL);
$arrMarker = array();
$arrDescription = array();
$description="";
$numId=0;
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
//print_r($row);echo "<hr>";
//$id = $row['OBJECTID'];
$id=$numId;
$numLng = $row['XGCSWGS84'];
$numLat = $row['YGCSWGS84'];
if ($row['IstRad']) $description .="mit Fahrradbeteiligung, ";
if ($row['IstPKW']) $description .="mit PKW-Beteiligung, ";
if ($row['IstFuss']) $description .="mit Fußgängerbeteiligung, ";
if ($row['IstKrad']) $description .="mit Kraftradbeteiligung, ";
if ($row['IstGkfz']) $description .="mit Güterkraftzeugbeteiligung, ";
if ($row['IstSonstige']) $description .="mit Beteiligung eines oben nicht genannten Verkehrsmittels";
$strDescription=generate_tooltip_description($row);
$strCategory=generate_category($row);
$arrMarker[]="marker[".$id."] = [L.marker([".$numLat."," .$numLng."],"
." { icon: ".$arrMarkerType[$topic]." }),'".$strCategory."'];\n"
."marker[".$id."][0].addTo(mymap);\n "
."marker[".$id."][0].bindPopup('".$strDescription."');";
$numId++;
}
$markerid=$id+1;
/*
marker[val.id] = [L.marker([val.lat, val.lng], { "icon": L.MakiMarkers.icon({ "color": color, "size": "m", "icon": "circle" }) }).bindPopup(html), val.membertype];
marker[val.id][0].addTo(map);
*/
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="de"> <html lang="de">
@ -189,6 +74,9 @@
</select> </select>
</form> </form>
<ul class="navbar-nav mr-auto right"> <ul class="navbar-nav mr-auto right">
<li class="nav-item">
<a class="nav-link" href="statistics/">Statistik</a>
</li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="impressum.php">Impressum</a> <a class="nav-link" href="impressum.php">Impressum</a>
</li> </li>

110
lib/init.php Normal file
View File

@ -0,0 +1,110 @@
<?php
$result= $db->prepare("SELECT count(*) FROM district WHERE district=:district");
$result->bindParam(":district",$strDistrict);
$result->execute();
if ($row=$result->fetch(PDO::FETCH_NUM)) {
if ($row[0]==0) $strDistrict="hamm";
}
//$result = $db->query($strSQL);
$result= $db->prepare("SELECT * FROM district WHERE district=:district");
$result->bindParam(":district",$strDistrict);
$result->execute();
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$strDistrict = $row['district'];
$strTitle = $row['title'];
$strGeojson = $row['geojson'];
$numULAND=$row['ULAND'];
$numUREGBEZ=$row['UREGBEZ'];
$numUKREIS=$row['UKREIS'];
$numUGEMEINDE=$row['UGEMEINDE'];
$numInfoLat=$row['lat'];
$numInfoLng=$row['lng'];
$numZoom=$row['zoom'];
$strTitle = "Unfallkarte $strTitle ";
$strIntroText = "$strTitle basierend auf den Daten des Statistischen Bundesamtes.";
$fileGeojson ="geojson/$strGeojson";
$strLocation = " AND ULAND=$numULAND AND UREGBEZ=$numUREGBEZ AND UKREIS=$numUKREIS ";
if ($numUGEMEINDE>0) {
$strLocation .= "AND UGEMEINDE=$numUGEMEINDE";
}
}
$arrDisctrict = array ();
$strSQL = "SELECT district,title FROM district ORDER BY title ASC";
$result=$db->query($strSQL);
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$arrDistrict[$row['district']]=$row['title'];
}
$strIntro ="<h4>".$strTitle."</h4>";
$strIntro .= nl2br2($strIntroText);
switch ($numVehicle) {
case 1:
case 0:
$strWhere ="IstRad = 1";
$topic=2;
break;
case 2:
$strWhere = "IstPKW = 1";
$topic=4;
break;
case 3:
$strWhere = "IstFuss = 1";
$topic=1;
break;
case 4:
$strWhere = "IstKrad = 1";
$topic=0;
break;
case 5:
$strWhere = "IstGkfz = 1";
$topic=5;
break;
case 6:
$strWhere = "IstSonstige = 1";
$topic=3;
break;
default: $strWhere ="IstRad = 1";
$topic=2;
}
$strYear = " AND UJAHR='".$numYear."' ";
$strSQL="SELECT * FROM data WHERE ".$strWhere.$strYear.$strLocation;
$result = $db->query($strSQL);
$arrMarker = array();
$arrDescription = array();
$description="";
$numId=0;
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
//print_r($row);echo "<hr>";
//$id = $row['OBJECTID'];
$id=$numId;
$numLng = $row['XGCSWGS84'];
$numLat = $row['YGCSWGS84'];
if ($row['IstRad']) $description .="mit Fahrradbeteiligung, ";
if ($row['IstPKW']) $description .="mit PKW-Beteiligung, ";
if ($row['IstFuss']) $description .="mit Fußgängerbeteiligung, ";
if ($row['IstKrad']) $description .="mit Kraftradbeteiligung, ";
if ($row['IstGkfz']) $description .="mit Güterkraftzeugbeteiligung, ";
if ($row['IstSonstige']) $description .="mit Beteiligung eines oben nicht genannten Verkehrsmittels";
$strDescription=generate_tooltip_description($row);
$strCategory=generate_category($row);
$arrMarker[]="marker[".$id."] = [L.marker([".$numLat."," .$numLng."],"
." { icon: ".$arrMarkerType[$topic]." }),'".$strCategory."'];\n"
."marker[".$id."][0].addTo(mymap);\n "
."marker[".$id."][0].bindPopup('".$strDescription."');";
$numId++;
}
$markerid=$id+1;

View File

@ -6,32 +6,69 @@
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>Fahrrad-Unfallstatistik NRW</title> <title>Fahrrad-Unfallstatistik NRW</title>
<link rel="stylesheet" href="../css/bootstrap.min.css"/> <link rel="stylesheet" href="../css/bootstrap.min.css"/>
<link rel="stylesheet" href="//cdn.datatables.net/1.13.6/css/jquery.dataTables.min.css">
<script src="../js/jquery.min.js"></script>
<script src="//cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>
<style> <style>
.rechts {text-align:right;background-color:#eee;} .rechts {text-align:right;background-color:#eee;}
.l {border-left: 1px solid black; } .l {border-left: 1px solid black; }
</style> </style>
</head> </head>
<body> <body>
<div class="container my-5"> <!-- Navbar -->
<h1>Fahrradunfälle in Nordrhein-Westfalen in Gemeinden</h2> <nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
<table class="table table-striped table-sm"> <a class="navbar-brand" href="#">Unfallkarte</a>
<tr><th></th> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbars" aria-controls="navbars" aria-expanded="false" aria-label="Toggle navigation">
<th colspan="4">Fahrradunfälle</th> <span class="navbar-toggler-icon"></span>
<th colspan="4">Todesfälle</th> </button>
<th colspan="4">Schwerverletzte</th> <div class="collapse navbar-collapse" id="navbars">
<th colspan="4">Leichtverletzte</th> <ul class="navbar-nav mr-auto">
<th class='l'>Fäche</th> <li class="nav-item">
<th>Einw.</th> <a class="nav-link" href="../index.php">Karte</a>
<th>Quote</th> </li>
</ul>
</tr> <div>
<tr><th>Kreis</th> <ul class="navbar-nav mr-auto right">
<th class='l'>2022</th><th>2021</th><th>2020</th><th>2019</th> <li class="nav-item active">
<th class='l'>2022</th><th>2021</th><th>2020</th><th>2019</th> <a class="nav-link" href="index.php">Statistik <span class="sr-only">(current)</span></a>
<th class='l'>2022</th><th>2021</th><th>2020</th><th>2019</th> </li>
<th class='l'>2022</th><th>2021</th><th>2020</th><th>2019</th> <li class="nav-item">
<th class='l' colspan="2">in Tausend</th><th></th> <a class="nav-link" href="../impressum.php">Impressum</span></a>
</tr> </li>
<li class="nav-item">
<a class="nav-link" href="../datenschutz.php">Datenschutzerklärung</a>
</li>
</ul>
</div>
</nav>
<!-- Ende Navbar -->
<div class="container-fluid">
<h1>Fahrradunfälle in Nordrhein-Westfalen in Gemeinden</h2>
<table id="unfallzahlen" class="display">
<thead>
<tr><th></th>
<th colspan="4">Fahrradunfälle</th>
<th colspan="4">Todesfälle</th>
<th colspan="4">Schwerverletzte</th>
<th colspan="4">Leichtverletzte</th>
<th class='l'>Fäche</th>
<th>Einw.</th>
<th>Quote</th>
</tr>
<tr><th>Name</th>
<th class='l'>2022</th><th>2021</th><th>2020</th><th>2019</th>
<th class='l'>2022</th><th>2021</th><th>2020</th><th>2019</th>
<th class='l'>2022</th><th>2021</th><th>2020</th><th>2019</th>
<th class='l'>2022</th><th>2021</th><th>2020</th><th>2019</th>
<th class='l' colspan="2">in Tausend</th><th></th>
</tr>
</thead>
<tbody>
<?php <?php
require("../config.php"); require("../config.php");
@ -92,8 +129,13 @@ while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
echo "<td class='rechts'>".round($row['Quote_2022'],2)."</td>"; echo "<td class='rechts'>".round($row['Quote_2022'],2)."</td>";
echo "</tr>\n"; echo "</tr>\n";
} }
echo "</table>\n";
?> ?>
</tbody>
</table>
</div> </div>
</body> </body>
<script>
let table = new DataTable('#unfallzahlen');
</script>
</html> </html>

View File

@ -1,95 +1,59 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="de"> <html lang="de">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Fahrrad-Unfallstatistik NRW</title>
<link rel="stylesheet" href="../css/bootstrap.min.css"/>
<style>
.rechts {text-align:right;}
.l {border-left: 1px solid black; }
</style>
</head>
<body>
<div class="container my-5">
<h1>Fahrradunfälle in Nordrhein-Westfalen in Kreisen und kreisfreien Städten</h2>
<table class="table table-striped table-sm">
<tr><th></th>
<th colspan="4">Fahrradunfälle</th>
<th colspan="4">Todesfälle</th>
<th colspan="4">Schwerverletzte</th>
<th colspan="4">Leichtverletzte</th>
<th></th><th></th>
</tr>
<tr><th>Kreis</th>
<th class="l">2022</th><th>2021</th><th>2020</th><th>2019</th>
<th class="l">2022</th><th>2021</th><th>2020</th><th>2019</th>
<th class="l">2022</th><th>2021</th><th>2020</th><th>2019</th>
<th class="l">2022</th><th>2021</th><th>2020</th><th>2019</th>
<th class="l">Einw. in Tausend</th><th>Quote</th>
</tr> <head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Unfallstatistik</title>
<link rel="stylesheet" href="../css/bootstrap.min.css" />
<link rel="stylesheet" href="../css/style.css" />
</head>
<body>
<?php <!-- Navbar -->
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
<a class="navbar-brand" href="#">Unfallkarte</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbars" aria-controls="navbars" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbars">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="../index.php">Karte</a>
</li>
</ul>
require("../config.php"); <div>
<ul class="navbar-nav mr-auto right">
<li class="nav-item active">
<a class="nav-link" href="index.php">Statistik <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="../impressum.php">Impressum</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="../datenschutz.php">Datenschutzerklärung</a>
</li>
</ul>
</div>
</nav>
<!-- Ende Navbar -->
$strSQL="SELECT d.title as Kreis, <div class="container main">
SUM(UJAHR=2022) as Jahr_2022,
SUM(UJAHR=2021) as Jahr_2021,
SUM(UJAHR=2020) as Jahr_2020,
SUM(UJAHR=2019) as Jahr_2019,
SUM(UJAHR=2022 AND UKATEGORIE=1) as Tode_2022, <p>&nbsp;</p>
SUM(UJAHR=2021 AND UKATEGORIE=1) as Tode_2021, <div class="card">
SUM(UJAHR=2020 AND UKATEGORIE=1) as Tode_2020, <div class="card-header"><h2>Statistik zu Unfällen in NRW</h2></div>
SUM(UJAHR=2019 AND UKATEGORIE=1) as Tode_2019, <div class="card-body">
SUM(UJAHR=2022 AND UKATEGORIE=2) as Schwerverletzt_2022, <h3>Weitere Auswertungen zu Fahrradunfällen</h3>
SUM(UJAHR=2021 AND UKATEGORIE=2) as Schwerverletzt_2021, <ul>
SUM(UJAHR=2020 AND UKATEGORIE=2) as Schwerverletzt_2020, <li><a href="kreise.php">Fahrradunfälle nach Kreisen und kreisfreien Städten</a></li>
SUM(UJAHR=2019 AND UKATEGORIE=2) as Schwerverletzt_2019, <li><a href="gemeinden.php">Fahrradunfälle nach Gemeinden</a></li>
</ul>
SUM(UJAHR=2022 AND UKATEGORIE=3) as Leichtverletzt_2022,
SUM(UJAHR=2021 AND UKATEGORIE=3) as Leichtverletzt_2021,
SUM(UJAHR=2020 AND UKATEGORIE=3) as Leichtverletzt_2020,
SUM(UJAHR=2019 AND UKATEGORIE=3) as Leichtverletzt_2019,
d.Population as Population,
SUM(UJAHR=2022)/d.Population*1000 as Quote_2022
FROM data s, district d
WHERE IstRad=1
AND d.ULAND=s.ULAND AND d.UREGBEZ=s.UREGBEZ AND d.UKREIS=s.UKREIS
GROUP BY s.ULAND, s.UREGBEZ, s.UKREIS
ORDER BY Quote_2022 DESC;";
$result=$db->query($strSQL);
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
echo "<tr>";
echo "<td>".$row['Kreis']."</td>";
echo "<td class='l'>".$row['Jahr_2022']."</td>";
echo "<td>".$row['Jahr_2021']."</td>";
echo "<td>".$row['Jahr_2020']."</td>";
echo "<td>".$row['Jahr_2019']."</td>";
echo "<td class='l'>".$row['Tode_2022']."</td>";
echo "<td>".$row['Tode_2021']."</td>";
echo "<td>".$row['Tode_2020']."</td>";
echo "<td>".$row['Tode_2019']."</td>";
echo "<td class='l'>".$row['Schwerverletzt_2022']."</td>";
echo "<td>".$row['Schwerverletzt_2021']."</td>";
echo "<td>".$row['Schwerverletzt_2020']."</td>";
echo "<td>".$row['Schwerverletzt_2019']."</td>";
echo "<td class='l'>".$row['Leichtverletzt_2022']."</td>";
echo "<td>".$row['Leichtverletzt_2021']."</td>";
echo "<td>".$row['Leichtverletzt_2020']."</td>";
echo "<td>".$row['Leichtverletzt_2019']."</td>";
echo "<td class='l rechts'>".round($row['Population']/1000,0)."</td>";
echo "<td class='rechts'>".round($row['Quote_2022'],2)."</td>";
echo "</tr>\n";
}
echo "</table>\n";
?>
</div> </div>
</div>
</body> </body>
</html> </html>

139
statistics/kreise.php Normal file
View File

@ -0,0 +1,139 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Fahrrad-Unfallstatistik NRW</title>
<link rel="stylesheet" href="../css/bootstrap.min.css"/>
<link rel="stylesheet" href="//cdn.datatables.net/1.13.6/css/jquery.dataTables.min.css">
<script src="../js/jquery.min.js"></script>
<script src="//cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>
<style>
.rechts {text-align:right;}
.l {border-left: 1px solid black; }
</style>
</head>
<body>
<!-- Navbar -->
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
<a class="navbar-brand" href="#">Unfallkarte</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbars" aria-controls="navbars" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbars">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="../index.php">Karte</a>
</li>
</ul>
<div>
<ul class="navbar-nav mr-auto right">
<li class="nav-item active">
<a class="nav-link" href="index.php">Statistik <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="../impressum.php">Impressum</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="../datenschutz.php">Datenschutzerklärung</a>
</li>
</ul>
</div>
</nav>
<!-- Ende Navbar -->
<div class="container-fluid">
<h1>Fahrradunfälle in Nordrhein-Westfalen in Kreisen und kreisfreien Städten</h2>
<table id="unfallzahlen" class="display">
<thead>
<tr><th></th>
<th colspan="4">Fahrradunfälle</th>
<th colspan="4">Todesfälle</th>
<th colspan="4">Schwerverletzte</th>
<th colspan="4">Leichtverletzte</th>
<th></th><th></th>
</tr>
<tr><th>Kreis</th>
<th class="l">2022</th><th>2021</th><th>2020</th><th>2019</th>
<th class="l">2022</th><th>2021</th><th>2020</th><th>2019</th>
<th class="l">2022</th><th>2021</th><th>2020</th><th>2019</th>
<th class="l">2022</th><th>2021</th><th>2020</th><th>2019</th>
<th class="l">Einw. in Tausend</th><th>Quote</th>
</tr>
</thead>
<tbody>
<?php
require("../config.php");
$strSQL="SELECT d.title as Kreis,
SUM(UJAHR=2022) as Jahr_2022,
SUM(UJAHR=2021) as Jahr_2021,
SUM(UJAHR=2020) as Jahr_2020,
SUM(UJAHR=2019) as Jahr_2019,
SUM(UJAHR=2022 AND UKATEGORIE=1) as Tode_2022,
SUM(UJAHR=2021 AND UKATEGORIE=1) as Tode_2021,
SUM(UJAHR=2020 AND UKATEGORIE=1) as Tode_2020,
SUM(UJAHR=2019 AND UKATEGORIE=1) as Tode_2019,
SUM(UJAHR=2022 AND UKATEGORIE=2) as Schwerverletzt_2022,
SUM(UJAHR=2021 AND UKATEGORIE=2) as Schwerverletzt_2021,
SUM(UJAHR=2020 AND UKATEGORIE=2) as Schwerverletzt_2020,
SUM(UJAHR=2019 AND UKATEGORIE=2) as Schwerverletzt_2019,
SUM(UJAHR=2022 AND UKATEGORIE=3) as Leichtverletzt_2022,
SUM(UJAHR=2021 AND UKATEGORIE=3) as Leichtverletzt_2021,
SUM(UJAHR=2020 AND UKATEGORIE=3) as Leichtverletzt_2020,
SUM(UJAHR=2019 AND UKATEGORIE=3) as Leichtverletzt_2019,
d.Population as Population,
SUM(UJAHR=2022)/d.Population*1000 as Quote_2022
FROM data s, district d
WHERE IstRad=1
AND d.ULAND=s.ULAND AND d.UREGBEZ=s.UREGBEZ AND d.UKREIS=s.UKREIS
GROUP BY s.ULAND, s.UREGBEZ, s.UKREIS
ORDER BY Quote_2022 DESC;";
$result=$db->query($strSQL);
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
echo "<tr>";
echo "<td>".$row['Kreis']."</td>";
echo "<td class='l'>".$row['Jahr_2022']."</td>";
echo "<td>".$row['Jahr_2021']."</td>";
echo "<td>".$row['Jahr_2020']."</td>";
echo "<td>".$row['Jahr_2019']."</td>";
echo "<td class='l'>".$row['Tode_2022']."</td>";
echo "<td>".$row['Tode_2021']."</td>";
echo "<td>".$row['Tode_2020']."</td>";
echo "<td>".$row['Tode_2019']."</td>";
echo "<td class='l'>".$row['Schwerverletzt_2022']."</td>";
echo "<td>".$row['Schwerverletzt_2021']."</td>";
echo "<td>".$row['Schwerverletzt_2020']."</td>";
echo "<td>".$row['Schwerverletzt_2019']."</td>";
echo "<td class='l'>".$row['Leichtverletzt_2022']."</td>";
echo "<td>".$row['Leichtverletzt_2021']."</td>";
echo "<td>".$row['Leichtverletzt_2020']."</td>";
echo "<td>".$row['Leichtverletzt_2019']."</td>";
echo "<td class='l rechts'>".round($row['Population']/1000,0)."</td>";
echo "<td class='rechts'>".round($row['Quote_2022'],2)."</td>";
echo "</tr>\n";
}
?>
</tbody>
</table>
<script>
let table = new DataTable('#unfallzahlen');
</script>
</div>
</body>
</html>