Set custom duration for minigraphs

This commit is contained in:
Alexandre
2024-11-26 10:06:59 +01:00
committed by Nachtzuster
parent 4680b7258e
commit f9d166d4f0
+3 -1
View File
@@ -59,9 +59,11 @@ $totalspeciestally = $result6->fetchArray(SQLITE3_ASSOC);
if(isset($_GET['comname'])) {
$birdName = htmlspecialchars_decode($_GET['comname'], ENT_QUOTES);
// Set default days to 30 if not provided
$days = isset($_GET['days']) ? intval($_GET['days']) : 30;
// Prepare a SQL statement to retrieve the detection data for the specified bird
$stmt = $db->prepare('SELECT Date, COUNT(*) AS Detections FROM detections WHERE Com_Name = :com_name AND Date BETWEEN DATE("now", "-30 days") AND DATE("now") GROUP BY Date');
$stmt = $db->prepare('SELECT Date, COUNT(*) AS Detections FROM detections WHERE Com_Name = :com_name AND Date BETWEEN DATE("now", "-' . $days . ' days") AND DATE("now") GROUP BY Date');
// Bind the bird name parameter to the SQL statement
$stmt->bindValue(':com_name', $birdName);