From 746867c67717e650da1d5b83ab8ffdc17f8e3b22 Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Sun, 1 May 2022 10:57:22 -0400 Subject: [PATCH] Adding search to Today's Detections --- scripts/todays_detections.php | 42 ++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/scripts/todays_detections.php b/scripts/todays_detections.php index 2f25575..475e000 100644 --- a/scripts/todays_detections.php +++ b/scripts/todays_detections.php @@ -58,11 +58,16 @@ $result6 = $statement6->execute(); $totalspeciestally = $result6->fetchArray(SQLITE3_ASSOC); if(isset($_GET['ajax_detections']) && $_GET['ajax_detections'] == "true" ) { + if(isset($_GET['searchterm'])) { + $searchquery = "AND (Com_name LIKE '%".$_GET['searchterm']."%' OR Sci_name LIKE '%".$_GET['searchterm']."%' OR Confidence LIKE '%".$_GET['searchterm']."%' OR File_Name LIKE '%".$_GET['searchterm']."%' OR Time LIKE '%".$_GET['searchterm']."%')"; + } else { + $searchquery = ""; + } if(isset($_GET['display_limit']) && is_numeric($_GET['display_limit'])){ - $statement0 = $db->prepare('SELECT Time, Com_Name, Sci_Name, Confidence, File_Name FROM detections WHERE Date == Date(\'now\', \'localtime\') ORDER BY Time DESC LIMIT '.(intval($_GET['display_limit'])-40).',40'); + $statement0 = $db->prepare('SELECT Time, Com_Name, Sci_Name, Confidence, File_Name FROM detections WHERE Date == Date(\'now\', \'localtime\') '.$searchquery.' ORDER BY Time DESC LIMIT '.(intval($_GET['display_limit'])-40).',40'); } else { // legacy mode - $statement0 = $db->prepare('SELECT Time, Com_Name, Sci_Name, Confidence, File_Name FROM detections WHERE Date == Date(\'now\', \'localtime\') ORDER BY Time DESC '); + $statement0 = $db->prepare('SELECT Time, Com_Name, Sci_Name, Confidence, File_Name FROM detections WHERE Date == Date(\'now\', \'localtime\') '.$searchquery.' ORDER BY Time DESC'.$searchquery); } if($statement0 == False){ echo "Database is busy"; @@ -151,7 +156,7 @@ if(isset($_GET['ajax_detections']) && $_GET['ajax_detections'] == "true" ) { -