From ebff1f3d78c5b9ed2226d54c58d2a48088015e73 Mon Sep 17 00:00:00 2001 From: Brian Read Date: Sun, 30 Jun 2024 09:10:57 +0100 Subject: [PATCH] fix select for all hours on Summary logs page --- root/opt/mailstats/html/showSummaryLogs.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) mode change 100755 => 100644 root/opt/mailstats/html/showSummaryLogs.php diff --git a/root/opt/mailstats/html/showSummaryLogs.php b/root/opt/mailstats/html/showSummaryLogs.php old mode 100755 new mode 100644 index fe8960b..9f2535e --- a/root/opt/mailstats/html/showSummaryLogs.php +++ b/root/opt/mailstats/html/showSummaryLogs.php @@ -8,8 +8,8 @@ $dbname = "mailstats"; // Default date to yesterday $date = isset($_GET['date']) ? $_GET['date'] : date('Y-m-d', strtotime('-1 day')); -// Default hour to 12 -$hour = isset($_GET['hour']) ? $_GET['hour'] : 12; +// Default hour to 99 (means all the hours) +$hour = isset($_GET['hour']) ? $_GET['hour'] : 99; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); @@ -20,9 +20,15 @@ if ($conn->connect_error) { } // Prepare and execute the query -$sql = "SELECT * FROM SummaryLogs WHERE Date = ? AND Hour = ?"; -$stmt = $conn->prepare($sql); -$stmt->bind_param("si", $date, $hour); +if ($hour == 99){ + $sql = "SELECT * FROM SummaryLogs WHERE Date = ?"; + $stmt = $conn->prepare($sql); + $stmt->bind_param("s", $date); +} else { + $sql = "SELECT * FROM SummaryLogs WHERE Date = ? AND Hour = ?"; + $stmt = $conn->prepare($sql); + $stmt->bind_param("si", $date, $hour); +} $stmt->execute(); $result = $stmt->get_result(); @@ -82,7 +88,7 @@ function generateLogDataTable($logData) { -

Summary Logs for Date: and Hour:

+

Summary Logs for Date: