fix select for all hours on Summary logs page
This commit is contained in:
parent
e94c96cb26
commit
ebff1f3d78
18
root/opt/mailstats/html/showSummaryLogs.php
Executable file → Normal file
18
root/opt/mailstats/html/showSummaryLogs.php
Executable file → Normal file
@ -8,8 +8,8 @@ $dbname = "mailstats";
|
|||||||
// Default date to yesterday
|
// Default date to yesterday
|
||||||
$date = isset($_GET['date']) ? $_GET['date'] : date('Y-m-d', strtotime('-1 day'));
|
$date = isset($_GET['date']) ? $_GET['date'] : date('Y-m-d', strtotime('-1 day'));
|
||||||
|
|
||||||
// Default hour to 12
|
// Default hour to 99 (means all the hours)
|
||||||
$hour = isset($_GET['hour']) ? $_GET['hour'] : 12;
|
$hour = isset($_GET['hour']) ? $_GET['hour'] : 99;
|
||||||
|
|
||||||
// Create connection
|
// Create connection
|
||||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||||
@ -20,9 +20,15 @@ if ($conn->connect_error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Prepare and execute the query
|
// Prepare and execute the query
|
||||||
$sql = "SELECT * FROM SummaryLogs WHERE Date = ? AND Hour = ?";
|
if ($hour == 99){
|
||||||
$stmt = $conn->prepare($sql);
|
$sql = "SELECT * FROM SummaryLogs WHERE Date = ?";
|
||||||
$stmt->bind_param("si", $date, $hour);
|
$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();
|
$stmt->execute();
|
||||||
$result = $stmt->get_result();
|
$result = $stmt->get_result();
|
||||||
|
|
||||||
@ -82,7 +88,7 @@ function generateLogDataTable($logData) {
|
|||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Summary Logs for Date: <?= htmlspecialchars($date) ?> and Hour: <?= htmlspecialchars($hour) ?></h1>
|
<h1>Summary Logs for Date: <?= htmlspecialchars($date) ?> <?= $hour == 99 ? 'for All Hours' : 'and Hour: ' . htmlspecialchars($hour) ?></h1>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
Loading…
Reference in New Issue
Block a user