connect_error) { die("Connection failed: " . $conn->connect_error); } // Prepare and execute the query 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(); $result_count = $result->num_rows; function generateLogDataTable($logData) { $data = json_decode($logData, true); if (is_null($data)) { return "Invalid JSON data"; } //// Remove entries with the key "logterse" //if (isset($data['logterse'])) { //unset($data['logterse']); //} // Remove entries with the key "logterse" and remove entries with empty values foreach ($data as $key => $value) { if ($key === 'logterse' || empty($value)) { unset($data[$key]); } } // Handle adjacent duplicates by merging keys $mergedData = []; $previousValue = null; foreach ($data as $key => $value) { if ($value === $previousValue) { // Merge the current key with the previous key end($mergedData); $lastKey = key($mergedData); $newKey = "$lastKey/$key"; $mergedData[$newKey] = $value; // Remove the old entry unset($mergedData[$lastKey]); } else { // Otherwise, add a new entry $mergedData[$key] = $value; } $previousValue = $value; } $keys = array_keys($mergedData); $values = array_values($mergedData); $output = ''; // Divide keys and values into sets of 6 $chunks = array_chunk($keys, 6); foreach ($chunks as $chunkIndex => $chunk) { if ($chunkIndex > 0) { // Add spacing between different sets #$output .= ''; } $output .= ''; foreach ($chunk as $key) { $output .= ''; } $output .= ''; foreach ($chunk as $i => $key) { $output .= ''; } $output .= ''; } $output .= '
' . htmlspecialchars($key) . '
' . htmlspecialchars($values[$chunkIndex * 6+ $i]) . '
'; return $output; } ?> Summary Logs
"

Summary Logs for Date:

Found records.

num_rows > 0): ?> fetch_assoc()): ?>
Id Log Data
No records found for the specified date and hour.
close(); $conn->close(); ?>