Update view_log.php

This commit is contained in:
jakani24
2024-04-27 12:56:42 +02:00
parent d1e2d510fb
commit f58090206d

View File

@@ -25,6 +25,7 @@ $loglevel = htmlspecialchars(isset($_GET["loglevel"]) ? $_GET["loglevel"] : "");
$logtext = htmlspecialchars(isset($_GET["logtext"]) ? $_GET["logtext"] : "");
$machine_id = htmlspecialchars(isset($_GET["machine_id"]) ? $_GET["machine_id"] : "");
$time = htmlspecialchars(isset($_GET["time"]) ? $_GET["time"] : "");
//$location = htmlspecialchars(isset($_GET["time"]) ? $_GET["time"] : "");
$filter_query = "&loglevel=$loglevel&logtext=$logtext&machine_id=$machine_id&time=$time";
include "../../../config.php";
@@ -197,7 +198,7 @@ $conn->close();
$total_pages = ceil($total_entries / $page_size);
// Query log entries for the current page with filters
$sql = "SELECT * FROM log WHERE loglevel LIKE ? AND logtext LIKE ? AND machine_id LIKE ? AND time LIKE ? ORDER BY id DESC LIMIT ?, ?";
$sql = "SELECT * FROM log,machines WHERE loglevel LIKE ? AND logtext LIKE ? AND machine_id LIKE ? AND time LIKE ? AND machine_name=machine_id ORDER BY id DESC LIMIT ?, ?";
$stmt = $conn->prepare($sql);
$loglevel = "%" . $loglevel . "%";
$logtext = "%" . $logtext . "%";
@@ -214,7 +215,7 @@ $conn->close();
echo '<table class="table" style="overflow-x:auto">';
echo '<thead>';
echo '<tr>';
echo '<th>Entry id</th><th>Loglevel</th><th>Logtext</th><th>Machine id</th><th>Time & date</th><th>Delete entry</th>';
echo '<th>Entry id</th><th>Loglevel</th><th>Logtext</th><th>Machine id</th><th>Time & date</th><th>Location</th><th>Delete entry</th>';
echo '</tr>';
echo '</thead>';
echo '<tbody>';
@@ -227,7 +228,7 @@ $conn->close();
echo '<td><input type="text" class="form-control" name="loglevel" placeholder="' . str_replace("%","",$loglevel) . '"></td>';
echo '<td><input type="text" class="form-control" name="logtext" placeholder="' . str_replace("%","",$logtext) . '"></td>';
echo '<td><input type="text" class="form-control" name="machine_id" placeholder="' . str_replace("%","",$machine_id) . '"></td>';
//echo '<td><input type="text" class="form-control" name="time" placeholder="' . str_replace("%","",$machine_location) . '"></td>';
echo '<td><input type="text" class="form-control" name="time" placeholder="' . str_replace("%","",$machine_location) . '"></td>';
echo '<td><input type="text" class="form-control" name="time" placeholder="' . str_replace("%","",$time) . '"></td>';
echo '<td><button type="button" class="btn btn-danger" data-bs-toggle="modal" data-bs-target="#delete_all">Delete log</button></td>';
echo '</form>';
@@ -239,7 +240,7 @@ $conn->close();
echo '<td>' . $row["loglevel"] . '</td>';
echo '<td>' . $row["logtext"] . '</td>';
echo '<td>' . $row["machine_id"] . '</td>';
//echo '<td>' . $row["machine_location"] . '</td>';
echo '<td>' . $row["machine_location"] . '</td>';
echo '<td>' . $row["time"] . '</td>';
echo '<td><a href="view_log.php?delete=' . $row["id"] . $filter_query . '&page=' . $current_page . '">delete</a></td>';
echo '</tr>';