diff --git a/scripts/play.php b/scripts/play.php index bc16fd1..d24cd39 100644 --- a/scripts/play.php +++ b/scripts/play.php @@ -33,7 +33,11 @@ if(isset($_GET['byfilename'])){ $date = $_GET['date']; session_start(); $_SESSION['date'] = $date; - $statement = $db->prepare("SELECT DISTINCT(Com_Name) FROM detections WHERE Date == \"$date\" ORDER BY Com_Name"); + if(isset($_GET['sort']) && $_GET['sort'] == "occurrences") { + $statement = $db->prepare("SELECT DISTINCT(Com_Name) FROM detections WHERE Date == \"$date\" GROUP BY Com_Name ORDER BY COUNT(*) DESC"); + } else { + $statement = $db->prepare("SELECT DISTINCT(Com_Name) FROM detections WHERE Date == \"$date\" ORDER BY Com_Name"); + } if($statement == False){ echo "Database is busy"; header("refresh: 0;"); @@ -43,7 +47,11 @@ if(isset($_GET['byfilename'])){ #By Species } elseif(isset($_GET['byspecies'])) { - $statement = $db->prepare('SELECT DISTINCT(Com_Name) FROM detections ORDER BY Com_Name'); + if(isset($_GET['sort']) && $_GET['sort'] == "occurrences") { + $statement = $db->prepare('SELECT DISTINCT(Com_Name) FROM detections GROUP BY Com_Name ORDER BY COUNT(*) DESC'); + } else { + $statement = $db->prepare('SELECT DISTINCT(Com_Name) FROM detections ORDER BY Com_Name ASC'); + } session_start(); if($statement == False){ echo "Database is busy"; @@ -87,6 +95,53 @@ if(isset($_GET['byfilename'])){ if(!isset($_GET['species']) && !isset($_GET['filename'])){ ?>
+ +
+
+ + + + +
+
+ + + diff --git a/scripts/stats.php b/scripts/stats.php index c20bf51..e69de9d 100644 --- a/scripts/stats.php +++ b/scripts/stats.php @@ -8,19 +8,38 @@ if($db == False) { echo "Database busy"; header("refresh: 0;"); } -$statement = $db->prepare('SELECT Date, Time, File_Name, Com_Name, COUNT(*), MAX(Confidence) FROM detections GROUP BY Com_Name ORDER BY COUNT(*) DESC'); -if($statement == False) { - echo "Database busy"; - header("refresh: 0;"); -} -$result = $statement->execute(); -$statement2 = $db->prepare('SELECT Date, Time, File_Name, Com_Name, COUNT(*), MAX(Confidence) FROM detections GROUP BY Com_Name ORDER BY Com_Name'); -if($statement == False) { - echo "Database busy"; - header("refresh: 0;"); +if(isset($_GET['sort']) && $_GET['sort'] == "occurrences") { + + $statement = $db->prepare('SELECT Date, Time, File_Name, Com_Name, COUNT(*), MAX(Confidence) FROM detections GROUP BY Com_Name ORDER BY COUNT(*) DESC'); + if($statement == False) { + echo "Database busy"; + header("refresh: 0;"); + } + $result = $statement->execute(); + + $statement2 = $db->prepare('SELECT Date, Time, File_Name, Com_Name, COUNT(*), MAX(Confidence) FROM detections GROUP BY Com_Name ORDER BY COUNT(*) DESC'); + if($statement == False) { + echo "Database busy"; + header("refresh: 0;"); + } + $result2 = $statement2->execute(); +} else { + + $statement = $db->prepare('SELECT Date, Time, File_Name, Com_Name, COUNT(*), MAX(Confidence) FROM detections GROUP BY Com_Name ORDER BY Com_Name ASC'); + if($statement == False) { + echo "Database busy"; + header("refresh: 0;"); + } + $result = $statement->execute(); + + $statement2 = $db->prepare('SELECT Date, Time, File_Name, Com_Name, COUNT(*), MAX(Confidence) FROM detections GROUP BY Com_Name ORDER BY Com_Name ASC'); + if($statement == False) { + echo "Database busy"; + header("refresh: 0;"); + } + $result2 = $statement2->execute(); } -$result2 = $statement2->execute(); @@ -48,6 +67,48 @@ if(isset($_GET['species'])){
+
+ + + + + +
fetchArray(SQLITE3_ASSOC)) @@ -116,6 +177,7 @@ while($results=$result3->fetchArray(SQLITE3_ASSOC)){ }} ?>


+
fetchArray(SQLITE3_ASSOC))