<?php
include __DIR__ . '/../database/search_log_config.php';

$page = $_GET['page'] ?? 1;
$limit = 20;
$start = ($page-1)*$limit;

$result = $log_conn->query("
    SELECT * FROM search_logs
    ORDER BY id DESC
    LIMIT $start,$limit
");

while($row = $result->fetch_assoc()){
    echo "<tr>";
    echo "<td>{$row['id']}</td>";
    echo "<td>".htmlspecialchars($row['keyword'])."</td>";
    echo "<td>{$row['result_count']}</td>";
    echo "<td>{$row['ip_address']}</td>";
    echo "<td>{$row['searched_at']}</td>";
    echo "</tr>";
}