statistic

This commit is contained in:
Walter Hupfeld 2020-09-05 11:59:06 +02:00
parent 47ae3e17ee
commit c0124a05b6
2 changed files with 75 additions and 6 deletions

View File

@ -60,7 +60,6 @@
$strDescription=generate_tooltip_description($row); $strDescription=generate_tooltip_description($row);
$arrMarker[]="marker[".$id."] = [L.marker([".$numLat."," .$numLng."]," $arrMarker[]="marker[".$id."] = [L.marker([".$numLat."," .$numLng."],"
." { icon: ".$arrMarkerType[$topic]." }),'check_".$topic."'];\n" ." { icon: ".$arrMarkerType[$topic]." }),'check_".$topic."'];\n"
."marker[".$id."][0].addTo(mymap);\n " ."marker[".$id."][0].addTo(mymap);\n "
@ -134,12 +133,12 @@
<nav class="col-md-2 d-none d-md-block bg-light sidebar"> <nav class="col-md-2 d-none d-md-block bg-light sidebar">
<div class="sidebar-sticky"> <div class="sidebar-sticky">
<h2>Unfälle mit <?= $arrVehicles_pl[$numVehicle]; ?> </h2>
<ul class="nav flex-column"> <ul class="nav flex-column">
Unfälle mit <?php echo get_statistics($numVehicle,$strWhere); ?>
<?php
echo $arrVehicles_pl[$numVehicle];
?>
</ul> </ul>
</div> </div>
</nav> </nav>

View File

@ -83,3 +83,73 @@ function nl2br2($string) {
$string = str_replace(array("\r\n", "\r", "\n"), "<br />", $string); $string = str_replace(array("\r\n", "\r", "\n"), "<br />", $string);
return $string; return $string;
} }
function get_statistics($numVehicle,$strWhere) {
global $db;
$strSQL="SELECT
sum(IstRad) as rad,
sum(IstPKW) as pkw,
sum(IstFuss) as fuss,
sum(IstKrad) as krad,
sum(IstGkfz) as lkw,
sum(IstSonstige) as sonstiges,
count(*) as summe
FROM Unfallorte2019_Hamm
WHERE ".$strWhere;
$result = $db->query($strSQL);
$strTable="<table class='statistik'>";
$strTable.="<tr><th>Unfallbeteiligte</th><th>Anzahl</th></tr>";
while ($row = $result->fetchArray()) {
$strTable.="<tr><td>Fahrräder</td><td>".$row['rad']."</td></tr>";
$strTable.="<tr><td>PKWs</td><td>".$row['pkw']."</td></tr>";
$strTable.="<tr><td>Fussgänger</td><td>".$row['fuss']."</td></tr>";
$strTable.="<tr><td>Krafträder</td><td>".$row['krad']."</td></tr>";
$strTable.="<tr><td>LKWs</td><td>".$row['lkw']."</td></tr>";
$strTable.="<tr><td>Sonstiges</td><td>".$row['sonstiges']."</td></tr>";
}
/*
$strSQL="SELECT count(*) as count
FROM Unfallorte2019_Hamm
WHERE IstRad=0 and IstPKW=0 and IstFuss=0 and IstKrad=0 and IstGkfz=0 and IstSonstige=0";
*/
switch ($numVehicle) {
case 1:
case 0:
$strSQL="SELECT count(*) as count FROM Unfallorte2019_Hamm
WHERE IstPKW=0 and IstFuss=0 and IstKrad=0 and IstGkfz=0 and IstSonstige=0";
break;
case 2:
$strSQL="SELECT count(*) as count FROM Unfallorte2019_Hamm
WHERE IstRad=0 and IstFuss=0 and IstKrad=0 and IstGkfz=0 and IstSonstige=0";
break;
case 3:
$strSQL="SELECT count(*) as count FROM Unfallorte2019_Hamm
WHERE IstPKW=0 and IstRad=0 and IstKrad and IstGkfz=0 and IstSonstige=0";
break;
case 4:
$strSQL="SELECT count(*) as count FROM Unfallorte2019_Hamm
WHERE IstPKW=0 and IstFuss=0 and IstRad=0 and IstGkfz=0 and IstSonstige=0";
break;
case 5:
$strSQL="SELECT count(*) as count FROM Unfallorte2019_Hamm
WHERE IstPKW=0 and IstFuss=0 and IstKrad=0 and IstRad=0 and IstSonstige=0";
break;
case 6:
$strSQL="SELECT count(*) as count FROM Unfallorte2019_Hamm
WHERE IstPKW=0 and IstFuss=0 and IstKrad=0 and IstGkfz=0 and IstRad=0";
break;
}
$result = $db->query($strSQL);
if ($row = $result->fetchArray()) {
$strTable.="<tr><td>Alleinunfälle</td><td>".$row['count']."</td></tr>";
}
$strTable.="</table>";
return $strTable;
}