unfallkarte/statistics/nrw_details.php

149 lines
5.3 KiB
PHP
Raw Normal View History

2023-10-09 19:14:10 +02:00
<?php
require_once("../config.php");
2023-10-09 20:46:26 +02:00
require_once("../lib/attributes.php");
2023-10-10 18:45:24 +02:00
require_once("functions.php");
2023-10-09 19:14:10 +02:00
$numLand=5; // NRW
2023-10-11 13:13:53 +02:00
$strName="NRW";
2023-10-10 18:45:24 +02:00
$numJahr=$numLatestYear;
2023-10-11 13:13:53 +02:00
$strLocation=" AND ULAND=$numLand ";
2023-10-09 19:14:10 +02:00
// Name, Population und Fläche der Gemeinde
2023-10-11 13:13:53 +02:00
$result= $db->prepare("SELECT sum(Flaeche) as Flaeche, sum(Einwohner) as Einwohner FROM community WHERE ULAND=:land");
2023-10-09 19:14:10 +02:00
$result->bindParam(":land",$numLand);
2023-10-11 13:13:53 +02:00
2023-10-09 19:14:10 +02:00
$result->execute();
if ($row = $result->fetch(PDO::FETCH_ASSOC)) {
2023-10-11 13:13:53 +02:00
$numFlaeche=round($row['Flaeche'],0);
2023-10-09 19:14:10 +02:00
$numPopulation=$row['Einwohner'];
2023-10-10 11:04:06 +02:00
} else {exit;}
2023-10-09 19:14:10 +02:00
2023-10-10 11:04:06 +02:00
$resultUnfallzahlen = get_unfallzahlen($numJahr,$strLocation);
$resultUnfallart = get_unfallart($numJahr,$strLocation);
$resultUnfalltyp = get_unfalltyp($numJahr,$strLocation);
$resultBeteiligte = get_beteiligte($numJahr,$strLocation);
2023-10-10 18:45:24 +02:00
$resultVerlauf = get_verlauf($strLocation);
2023-10-10 11:04:06 +02:00
$numGesamt=0;
2023-10-09 20:46:26 +02:00
2023-10-09 19:14:10 +02:00
?>
<!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"/>
<script src="../js/jquery.min.js"></script>
2023-10-10 18:45:24 +02:00
<script src="../js/highcharts.js"></script>
2023-10-11 13:13:53 +02:00
<script src="../js/bootstrap.min.js"></script>
2023-10-09 19:14:10 +02:00
<style>
.rechts {text-align:right;background-color:#eee;}
.l {border-left: 1px solid black; }
</style>
</head>
<body>
2023-10-11 13:13:53 +02:00
<?php include("navbar.php"); ?>
2023-10-09 19:14:10 +02:00
<div class="container" style="margin-top:4em;">
2023-10-10 20:31:22 +02:00
<h1>Fahrradunfälle in <?=$strName?></h2>
2023-10-13 11:01:50 +02:00
<p>Einwohnerzahl: <?=number_format($numPopulation,0,",",".")?>&nbsp;&nbsp; Fläche: <?=number_format($numFlaeche,2,",",".")?> km<sup>2</sup></p>
2023-10-10 18:45:24 +02:00
<!-- Unfallverlauf -->
<div class="row">
<div class="col-5">
2023-10-10 20:31:22 +02:00
<h4>Unfallverlauf von <?=$numLatestYear?> bis <?=$numStartYear?></h4>
2023-10-10 18:45:24 +02:00
<table class='table table-sm'>
2024-07-05 10:35:43 +02:00
<tr><th></th><th>2023</th><th>2022</th><th>2021</th><th>2020</th><th>2019</th></tr>
2023-10-10 18:45:24 +02:00
<tr><td><?= $arrCategory[1]?></td><?= get_row($resultVerlauf,1) ?></tr>
<tr><td><?= $arrCategory[2]?></td><?= get_row($resultVerlauf,2) ?></tr>
<tr><td><?= $arrCategory[3]?></td><?= get_row($resultVerlauf,3) ?></tr>
<tr><th>Gesamt</th><?= get_row($resultVerlauf,0) ?></tr>
</table>
</div>
<div class="col-7">
<div id="c_unfallverlauf"></div>
</div>
</div>
2023-10-10 11:37:55 +02:00
<!-- Unfallzahlen -->
2023-10-09 20:46:26 +02:00
<div class="row">
2023-10-10 18:45:24 +02:00
<div class="col-5">
2023-10-10 20:29:18 +02:00
<h4>Unfallzahlen <?=$numJahr?></h4>
2023-10-09 20:46:26 +02:00
<table class="table table-sm">
2023-10-10 11:04:06 +02:00
<?php
//DEBUG echo "<pre>"; print_r($resultUnfallzahlen);echo "</pre>";
$numGesamt=0;
foreach ($resultUnfallzahlen as $row) {
echo "<tr><td>".$arrCategory[$row['UKATEGORIE']]."</td><td>".$row['anz']."</td></tr>\n";
$numGesamt+=$row['anz'];
}
?>
2023-10-09 20:46:26 +02:00
<tr><th>Gesamt</th><td><strong><?=$numGesamt?></strong></td></tr>
</table>
2023-10-10 11:37:55 +02:00
<table class="table table-sm">
2023-10-09 20:46:26 +02:00
<tr><th>Quote pro Tausend Einwohner</th><td><?= round($numGesamt/$numPopulation*1000,2) ?></td></tr>
2023-10-13 11:01:50 +02:00
<tr><th>Quote pro Fläche</th><td><?= number_format($numGesamt/$numFlaeche,2,",",".") ?> /km<sup>2</sup></td></tr>
2023-10-09 20:46:26 +02:00
</table>
</div>
2023-10-10 12:23:12 +02:00
<div class="col-7">
2023-10-10 11:37:55 +02:00
<div id="c_unfallzahlen"></div>
</div>
2023-10-09 20:46:26 +02:00
</div>
2023-10-10 11:37:55 +02:00
<!-- Unfallbeteilgte -->
2023-10-09 20:46:26 +02:00
<div class="row">
<div class="col-5">
<h4>Unfallbeteiligte</h4>
2023-10-10 11:04:06 +02:00
<table class='table table-sm'>
2023-10-09 20:46:26 +02:00
<?php
2023-10-10 11:04:06 +02:00
// DEBUG: echo "<pre>"; print_r($resultBeteiligte);echo "</pre>";
foreach ($resultBeteiligte as $key => $numCount) {
echo "<tr><td>".$arrBeteiligte[$key]."</td><td>".$numCount."</td></tr>\n";
}
?>
</table>
2023-10-09 20:46:26 +02:00
</div>
2023-10-10 12:22:16 +02:00
<div class="col-7">
<div id="c_unfallbeteiligte"></div>
</div>
2023-10-09 20:46:26 +02:00
</div>
2023-10-10 11:54:57 +02:00
<!-- Unfalltyp -->
2023-10-09 20:46:26 +02:00
<div class="row">
<div class="col-5">
<h4>Unfalltyp</h4>
2023-10-10 11:04:06 +02:00
<table class='table table-sm'>
2023-10-09 20:46:26 +02:00
<?php
2023-10-10 11:04:06 +02:00
foreach ($resultUnfalltyp as $row) {
echo "<tr><td>".$arrUnfalltyp[$row['UTYP1']]."</td><td>".$row['anz']."</td></tr>\n";
}
2023-10-09 20:46:26 +02:00
?>
2023-10-10 11:04:06 +02:00
</table>
2023-10-09 20:46:26 +02:00
</div>
2023-10-10 11:54:57 +02:00
<div class="col-7">
<div id="c_unfalltyp"></div>
</div>
2023-10-09 20:46:26 +02:00
</div>
2023-10-10 11:37:55 +02:00
<!-- Unfallarten -->
2023-10-09 20:46:26 +02:00
<div class="row">
<div class="col-5">
<h4>Unfallart</h4>
2023-10-10 11:04:06 +02:00
<table class='table table-sm'>
2023-10-09 20:46:26 +02:00
<?php
2023-10-10 11:04:06 +02:00
foreach ($resultUnfallart as $row) {
echo "<tr><td>".$arrUnfallart[$row['UART']]."</td><td>".$row['anz']."</td></tr>\n";
}
?>
</table>
2023-10-09 20:46:26 +02:00
</div>
2023-10-10 11:54:57 +02:00
<div class="col-7">
<div id="c_unfallarten"></div>
</div>
2023-10-09 20:46:26 +02:00
</div>
2023-10-09 19:14:10 +02:00
</div>
2023-10-10 11:37:55 +02:00
</body>
2023-10-12 08:32:20 +02:00
<?php include("highchart.php"); ?>
2023-10-09 19:14:10 +02:00
</html>