diff --git a/index.php b/index.php index 07988ca..323d2b6 100644 --- a/index.php +++ b/index.php @@ -60,7 +60,6 @@ $strDescription=generate_tooltip_description($row); - $arrMarker[]="marker[".$id."] = [L.marker([".$numLat."," .$numLng."]," ." { icon: ".$arrMarkerType[$topic]." }),'check_".$topic."'];\n" ."marker[".$id."][0].addTo(mymap);\n " @@ -134,12 +133,12 @@ diff --git a/lib/functions.php b/lib/functions.php index 9c6cf0a..31381fb 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -82,4 +82,74 @@ function read_gps_location($file){ function nl2br2($string) { $string = str_replace(array("\r\n", "\r", "\n"), "
", $string); return $string; - } \ No newline at end of file + } + + + 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=""; + $strTable.=""; + while ($row = $result->fetchArray()) { + $strTable.=""; + $strTable.=""; + $strTable.=""; + $strTable.=""; + $strTable.=""; + $strTable.=""; + + } + /* + $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.=""; + } + + $strTable.="
UnfallbeteiligteAnzahl
Fahrräder".$row['rad']."
PKWs".$row['pkw']."
Fussgänger".$row['fuss']."
Krafträder".$row['krad']."
LKWs".$row['lkw']."
Sonstiges".$row['sonstiges']."
Alleinunfälle".$row['count']."
"; + return $strTable; + } \ No newline at end of file