42 lines
1.7 KiB
PHP
42 lines
1.7 KiB
PHP
<?php
|
|
// Include file koneksi ke database
|
|
include '../config/database.php';
|
|
|
|
// Ambil kata kunci pencarian dari parameter GET
|
|
$search = isset($_GET['search']) ? $_GET['search'] : '';
|
|
|
|
// Query untuk mengambil data dari tabel kegiatan
|
|
$query = "SELECT * FROM kegiatan";
|
|
if ($search) {
|
|
$search = mysqli_real_escape_string($conn, $search);
|
|
$query .= " WHERE kegiatan_nama LIKE '%$search%'";
|
|
}
|
|
$query .= " ORDER BY kegiatan_tglmulai DESC";
|
|
|
|
$result = mysqli_query($conn, $query);
|
|
|
|
if (mysqli_num_rows($result) > 0) {
|
|
$no = 1;
|
|
while($row = mysqli_fetch_assoc($result)) {
|
|
echo "<tr>";
|
|
echo "<td scope='row'>" . $no . "</td>";
|
|
echo "<td>" . htmlspecialchars($row['kegiatan_nama']) . "</td>";
|
|
echo "<td>" . htmlspecialchars(date('d M Y', strtotime($row['kegiatan_tglmulai']))) . "</td>";
|
|
echo "<td>" . htmlspecialchars(date('d M Y', strtotime($row['kegiatan_tglakhir']))) . "</td>";
|
|
echo "<td>" . htmlspecialchars($row['kegiatan_keterangan']) . "</td>";
|
|
echo "<td><img src='../assets/img/kegiatan/" . htmlspecialchars($row['kegiatan_gambar']) . "' alt='Gambar Kegiatan' style='width: 100px;'></td>";
|
|
echo "<td>
|
|
<a href='tambahkegiatan.php?id=" . $row['kegiatan_id'] . "' class='btn btn-warning btn-sm'>Edit</a>
|
|
<a href='hapuskegiatan.php?id=" . $row['kegiatan_id'] . "' class='btn btn-danger btn-sm' onclick='return confirm(\"Yakin ingin menghapus kegiatan ini?\");'>Hapus</a>
|
|
</td>";
|
|
echo "</tr>";
|
|
$no++;
|
|
}
|
|
} else {
|
|
echo "<tr><td colspan='7' class='text-center'>Tidak ada kegiatan yang tersedia.</td></tr>";
|
|
}
|
|
|
|
// Tutup koneksi
|
|
mysqli_close($conn);
|
|
?>
|