connect_error) {
die("Connection failed: " . $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);
$stmt->execute();
$result = $stmt->get_result();
function generateLogDataTable($logData) {
$data = json_decode($logData, true);
if (is_null($data)) {
return "Invalid JSON data";
}
$keys = array_keys($data);
$values = array_values($data);
$output = '
';
// Divide keys and values into sets of 6
$chunks = array_chunk($keys, 7);
foreach ($chunks as $chunkIndex => $chunk) {
if ($chunkIndex > 0) {
// Add spacing between different sets
#$output .= ' |
';
}
$output .= '';
foreach ($chunk as $key) {
$output .= '' . htmlspecialchars($key) . ' | ';
}
$output .= '
';
foreach ($chunk as $i => $key) {
$output .= '' . htmlspecialchars($values[$chunkIndex * 7 + $i]) . ' | ';
}
$output .= '
';
}
$output .= '
';
return $output;
}
?>
Summary Logs
Summary Logs for Date: = htmlspecialchars($date) ?> and Hour: = htmlspecialchars($hour) ?>
Id |
Log Data |
num_rows > 0): ?>
fetch_assoc()): ?>
= htmlspecialchars($row['id']) ?> |
= generateLogDataTable($row['logData']) ?> |
No records found for the specified date and hour. |
close();
$conn->close();
?>