From f9d166d4f08049b2ba2b2569f707e5a3c9cca067 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Tue, 26 Nov 2024 10:06:59 +0100 Subject: [PATCH] Set custom duration for minigraphs --- scripts/todays_detections.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/todays_detections.php b/scripts/todays_detections.php index 06b0753..b00951e 100644 --- a/scripts/todays_detections.php +++ b/scripts/todays_detections.php @@ -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);