statistic
This commit is contained in:
		@@ -82,4 +82,74 @@ function read_gps_location($file){
 | 
			
		||||
function nl2br2($string) {
 | 
			
		||||
    $string = str_replace(array("\r\n", "\r", "\n"), "<br />", $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;
 | 
			
		||||
 }
 | 
			
		||||
		Reference in New Issue
	
	Block a user