This commit is contained in:
Walter Hupfeld
2023-10-10 11:04:06 +02:00
parent 6a550d2fb8
commit a98f0769bc
3 changed files with 78 additions and 77 deletions

View File

@@ -1,65 +1,55 @@
<?php
function get_beteiligte($strWhere,$strYear,$strLocation) {
function get_unfallzahlen($numYear,$strLocation) {
global $db;
$strSQL="SELECT
UKATEGORIE, count(UKATEGORIE) as anz
FROM data
WHERE IstRad=1 AND UJAHR=$numYear $strLocation
GROUP BY UKATEGORIE";
$result = $db->query($strSQL);
$arrResult = $result->fetchAll(PDO::FETCH_ASSOC);
return $arrResult;
}
function get_beteiligte($numYear,$strLocation) {
global $db;
$numVehicle=1;
$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
sum(IstSonstige) as sonstiges
FROM data
WHERE istRad=1 AND UJAHR =".$strYear.$strLocation;
WHERE istRad=1 AND UJAHR =".$numYear.$strLocation;
$result = $db->query($strSQL);
if ($row = $result->fetch(PDO::FETCH_ASSOC)) { $arrResult = $row; }
$strTable="<table class='table table-sm'>";
if ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$strTable.="<tr><td>Fahrräder</td><td>".$row['rad']."</td></tr>";
$strTable.="<tr><td>PKW</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>LKW</td><td>".$row['lkw']."</td></tr>\n";
$strTable.="<tr><td>Sonstiges</td><td>".$row['sonstiges']."</td></tr>\n";
}
$strSQL="SELECT count(*) as count FROM data
WHERE IstPKW=0 and IstFuss=0 and IstKrad=0 and IstGkfz=0 and IstSonstige=0".$strLocation;
$result = $db->query($strSQL." AND UJAHR=".$strYear);
WHERE UJAHR=".$numYear." AND IstPKW=0 and IstFuss=0 and IstKrad=0 and IstGkfz=0
and IstSonstige=0 ".$strLocation;
$result = $db->query($strSQL);
if ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$strTable.="<tr><td>Alleinunfälle und Unfälle mit geicher Fahrzeugart</td><td>".$row['count']."</td></tr>";
}
$strTable.="</table>";
return $strTable;
$arrResult["gleich"]=$row['count'];
}
return $arrResult;
}
function get_unfalltyp($strWhere,$strYear,$strLocation){
function get_unfalltyp($numYear,$strLocation){
global $db;
global $arrUnfalltyp;
$numVehicle=1;
$strSQL="SELECT UTYP1, count(UTYP1) as anz FROM data WHERE istRad=1 AND UJAHR=".$strYear.$strLocation." GROUP BY UTYP1";
$strTable="<table class='table table-sm'>";
$strSQL="SELECT UTYP1, count(UTYP1) as anz FROM data WHERE istRad=1 AND UJAHR=".$numYear.$strLocation." GROUP BY UTYP1";
$result = $db->query($strSQL);
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$strTable.="<tr><td>".$arrUnfalltyp[$row['UTYP1']]."</td><td>".$row['anz']."</td></tr>\n";
}
$strTable.="</table>";
return $strTable;
$arrResult = $result->fetchAll(PDO::FETCH_ASSOC);
return $arrResult;
}
function get_unfallart($strWhere,$strYear,$strLocation){
function get_unfallart($numYear,$strLocation){
global $db;
global $arrUnfallart;
$numVehicle=1;
$strSQL="SELECT UART, count(UART) as anz FROM data WHERE istRad=1 AND UJAHR=".$strYear.$strLocation." GROUP BY UART";
$strTable="<table class='table table-sm'>";
$strSQL="SELECT UART, count(UART) as anz FROM data WHERE istRad=1 AND UJAHR=".$numYear.$strLocation." GROUP BY UART";
$result = $db->query($strSQL);
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$strTable.="<tr><td>".$arrUnfallart[$row['UART']]."</td><td>".$row['anz']."</td></tr>\n";
}
$strTable.="</table>";
return $strTable;
$arrResult = $result->fetchAll(PDO::FETCH_ASSOC);
return $arrResult;
}