less work on the db
This commit is contained in:
+15
-13
@@ -1,4 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
ini_set('display_startup_errors', 1);
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
header("refresh: 30;");
|
header("refresh: 30;");
|
||||||
$mysqli = mysqli_connect();
|
$mysqli = mysqli_connect();
|
||||||
$mysqli->select_db('birds');
|
$mysqli->select_db('birds');
|
||||||
@@ -10,10 +14,9 @@ if ($mysqli->connect_error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SQL query to select data from database
|
// SQL query to select data from database
|
||||||
$sql = "SELECT * FROM detections
|
$sql = "SELECT COUNT(*) AS 'Total' FROM detections
|
||||||
ORDER BY Date DESC, Time DESC";
|
ORDER BY Date DESC, Time DESC";
|
||||||
$fulltable = $mysqli->query($sql);
|
$totalcount = $mysqli->query($sql);
|
||||||
$totalcount=mysqli_num_rows($fulltable);
|
|
||||||
|
|
||||||
$sql1 = "SELECT Date, Time, Sci_Name, Com_Name, MAX(Confidence)
|
$sql1 = "SELECT Date, Time, Sci_Name, Com_Name, MAX(Confidence)
|
||||||
FROM detections
|
FROM detections
|
||||||
@@ -22,26 +25,25 @@ $sql1 = "SELECT Date, Time, Sci_Name, Com_Name, MAX(Confidence)
|
|||||||
ORDER BY Time DESC";
|
ORDER BY Time DESC";
|
||||||
$mosttable = $mysqli->query($sql1);
|
$mosttable = $mysqli->query($sql1);
|
||||||
|
|
||||||
$sql2 = "SELECT * FROM detections
|
$sql2 = "SELECT COUNT(*) AS 'Total' FROM detections
|
||||||
WHERE Date = CURDATE()";
|
WHERE Date = CURDATE()";
|
||||||
$todaystable = $mysqli->query($sql2);
|
$todayscount = $mysqli->query($sql2);
|
||||||
$todayscount=mysqli_num_rows($todaystable);
|
|
||||||
|
|
||||||
$sql3 = "SELECT * FROM detections
|
$sql3 = "SELECT COUNT(*) AS 'Total' FROM detections
|
||||||
WHERE Date = CURDATE()
|
WHERE Date = CURDATE()
|
||||||
AND Time >= DATE_SUB(NOW(),INTERVAL 1 HOUR)";
|
AND Time >= DATE_SUB(NOW(),INTERVAL 1 HOUR)";
|
||||||
$lasthourtable = $mysqli->query($sql3);
|
$lasthourcount = $mysqli->query($sql3);
|
||||||
$lasthourcount=mysqli_num_rows($lasthourtable);
|
|
||||||
|
|
||||||
$sql4 = "SELECT Com_Name, Date, Time, MAX(Confidence)
|
$sql4 = "SELECT Com_Name, Date, Time, MAX(Confidence)
|
||||||
FROM detections
|
FROM detections
|
||||||
|
WHERE Date = CURDATE()
|
||||||
GROUP BY Com_Name
|
GROUP BY Com_Name
|
||||||
ORDER BY MAX(Confidence) DESC";
|
ORDER BY MAX(Confidence) DESC";
|
||||||
$specieslist = $mysqli->query($sql4);
|
$specieslist = $mysqli->query($sql4);
|
||||||
$speciescount = mysqli_num_rows($specieslist);
|
$speciescount = mysqli_num_rows($specieslist);
|
||||||
|
|
||||||
$sql5 = "SELECT Com_Name,COUNT(*)
|
$sql5 = "SELECT Com_Name,COUNT(*)
|
||||||
AS Total
|
AS 'Total'
|
||||||
FROM detections
|
FROM detections
|
||||||
GROUP BY Com_Name
|
GROUP BY Com_Name
|
||||||
ORDER BY Total DESC";
|
ORDER BY Total DESC";
|
||||||
@@ -73,9 +75,9 @@ $mysqli->close();
|
|||||||
<th>Number of Unique Species</th>
|
<th>Number of Unique Species</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><?php echo $totalcount;?></td>
|
<td><?php while ($row = $totalcount->fetch_assoc()) { echo $row['Total']; };?></td>
|
||||||
<td><?php echo $todayscount;?></td>
|
<td><?php while ($row = $todayscount->fetch_assoc()) { echo $row['Total']; };?></td>
|
||||||
<td><?php echo $lasthourcount;?></td>
|
<td><?php while ($row = $lasthourcount->fetch_assoc()) { echo $row['Total']; };?></td>
|
||||||
<td><?php echo $speciescount;?></td>
|
<td><?php echo $speciescount;?></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
Reference in New Issue
Block a user