saving changes

This commit is contained in:
mcguirepr89
2022-02-24 13:27:08 -05:00
parent cf0a3436f7
commit 10090f9411
11 changed files with 87 additions and 96 deletions
+27 -27
View File
@@ -10,24 +10,16 @@ if($db == False){
}
if(isset($_POST['bydate'])){
$statement = $db->prepare('SELECT DISTINCT(Date), Com_Name from detections GROUP BY Date');
$statement = $db->prepare('SELECT DISTINCT(Date), Com_Name FROM detections GROUP BY Date');
if($statement == False){
echo "Database is busy";
header("refresh: 0;");
}
$result = $statement->execute();
$view = "bydate";
} elseif(isset($_POST['byspecies'])) {
$statement = $db->prepare('SELECT DISTINCT(Com_Name) from detections ORDER BY Com_Name');
if($statement == False){
echo "Database is busy";
header("refresh: 0;");
}
$result = $statement->execute();
$view = "byspecies";
} elseif(isset($_POST['date'])) {
$date = $_POST['date'];
$statement = $db->prepare("SELECT DISTINCT(Com_Name) from detections WHERE Date == \"$date\" ORDER BY Com_Name");
$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;");
@@ -36,8 +28,8 @@ if(isset($_POST['bydate'])){
$view = "date";
} elseif(isset($_POST['species'])) {
$species = $_POST['species'];
$statement = $db->prepare("SELECT * from detections WHERE Com_Name == \"$species\" ORDER BY Com_Name");
$statement3 = $db->prepare("SELECT Date, Time, Com_Name, MAX(Confidence), File_Name from detections WHERE Com_Name == \"$species\" ORDER BY Com_Name");
$statement = $db->prepare("SELECT * FROM detections WHERE Com_Name == \"$species\" ORDER BY Com_Name");
$statement3 = $db->prepare("SELECT Date, Time, Com_Name, MAX(Confidence), File_Name FROM detections WHERE Com_Name == \"$species\" ORDER BY Com_Name");
if($statement == False || $statement3 == False){
echo "Database is busy";
header("refresh: 0;");
@@ -45,8 +37,15 @@ if(isset($_POST['bydate'])){
$result = $statement->execute();
$result3 = $statement3->execute();
$view = "species";
} else {
$statement = $db->prepare('SELECT DISTINCT(Com_Name) FROM detections ORDER BY Com_Name');
if($statement == False){
echo "Database is busy";
header("refresh: 0;");
}
$result = $statement->execute();
$view = "byspecies";
}
?>
<html>
@@ -57,7 +56,6 @@ if(isset($_POST['bydate'])){
</style>
</head>
<body>
<div class="column left">
<table>
<?php
if(!isset($_POST['species'])){
@@ -67,6 +65,7 @@ while($results=$result->fetchArray(SQLITE3_ASSOC))
<tr>
<form action="" method="POST">
<td>
<input type="hidden" name="view" value="Extractions">
<?php
if($view == "bydate"){
$date = $results['Date'];
@@ -82,23 +81,25 @@ while($results=$result->fetchArray(SQLITE3_ASSOC))
$maxconf = $results['MAX(Confidence)'];
$date = $results['Date'];
$time = $results['Time'];
$comname = preg_replace('/ /', '_', $results['Com_Name']);
$name = $results['Com_Name'];
$comname = preg_replace('/ /', '_', $name);
$comname = preg_replace('/\'/', '', $comname);
$file = $results['File_Name'];
$filename = "/By_Date/".$date."/".$comname."/".$results['File_Name'];
echo "<table>
<tr>
<th>$name</th>
<th>Max Confidence: $maxconf</th>
</tr>
<tr>
<td>Most confident recording: <a href=\"$filename\" target=\"footer\">$file</a></td>
<th>Most confident recording: </th>
<td><audio controls><source src=\"$filename\"></audio></td>
</tr></table>";
};};?>
</td>
</form>
</tr>
</table>
</div>
<div class="column right">
<?php
if(isset($_POST['species'])){
$name = $_POST['species'];
@@ -110,8 +111,8 @@ while($results=$result->fetchArray(SQLITE3_ASSOC))
$result2 = $statement2->execute();
echo "<table>
<tr>
<th>Date</th>
<th>Time</th>
<th>When</th>
<th>Listen</th>
<th>Scientific Name</th>
<th>Common Name</th>
<th>Confidence</th>
@@ -119,24 +120,23 @@ while($results=$result->fetchArray(SQLITE3_ASSOC))
while($results=$result2->fetchArray(SQLITE3_ASSOC))
{
$comname = preg_replace('/ /', '_', $results['Com_Name']);
$comname = preg_replace('/\'/', '', $comname);
$date = $results['Date'];
$comlink = "/By_Date/".$date."/".$comname."/".$results['File_Name'];
$filename = "/By_Date/".$date."/".$comname."/".$results['File_Name'];
$sciname = preg_replace('/ /', '_', $results['Sci_Name']);
$sci_name = $results['Sci_Name'];
$time = $results['Time'];
$confidence = $results['Confidence'];
echo "<tr>
<td>$date</td>
<td><a href=\"$comlink\" target=\"footer\"/>$time</a></td>
<td>$date $time</td>
<td><audio controls><source src=\"$filename\"></audio></td>
<td><a href=\"https://wikipedia.org/wiki/$sciname\" target=\"top\">$sci_name</a></td>
<form action=\"/stats.php\" method=\"POST\">
<td><button type=\"submit\" name=\"species\" value=\"$name\">$name</button>
<form action=\"\" method=\"POST\">
<td><input type=\"hidden\" name=\"view\" value=\"Species Stats\"><button type=\"submit\" name=\"species\" value=\"$name\">$name</button>
</form></td>
<td>$confidence</td>
</tr>";
}echo "</table>";}?>
</div>
</div>
</body>
</html>