<?php
include 'koneksi.php';

$keyword = isset($_GET['keyword']) ? $_GET['keyword'] : '';
$keyword = mysqli_real_escape_string($koneksi, $keyword);

$query = mysqli_query($koneksi,"
    SELECT * FROM berita
    WHERE judul LIKE '%$keyword%'
    ORDER BY id DESC
    LIMIT 10
");

while($row = mysqli_fetch_assoc($query)){
?>
<div class="card news-card">
    <div class="news-content">
        <h3><?= htmlspecialchars($row['judul']) ?></h3>
        <a href="detail_berita.php?id=<?= $row['id'] ?>">
            Baca Selengkapnya
        </a>
    </div>
</div>
<?php
}
?>