[ Mini Kiebo ]
Server: Windows NT AKFAR_SERVER 10.0 build 26200 (Windows 10) AMD64
Path:
D:
/
xampp
/
htdocs
/
campus
/
admin
/
[
Home
]
File: fasilitas.php
<?php session_start(); if (!isset($_SESSION['admin_logged_in'])) { header("Location: login.php"); exit; } include '../config/koneksi.php'; if (isset($_GET['hapus'])) { $id = $_GET['hapus']; $q = mysqli_query($conn, "SELECT gambar FROM fasilitas WHERE id='$id'"); $d = mysqli_fetch_assoc($q); if($d['gambar']) unlink("../uploads/".$d['gambar']); mysqli_query($conn, "DELETE FROM fasilitas WHERE id='$id'"); header("Location: fasilitas.php"); } ?> <!DOCTYPE html> <html lang="id"> <head> <title>Kelola Fasilitas</title> <style> body { font-family: sans-serif; padding: 20px; } table { width: 100%; border-collapse: collapse; margin-top: 20px; background: white; } th, td { padding: 12px; border: 1px solid #ddd; text-align: left; } th { background-color: #003366; color: white; } .btn { padding: 5px 10px; text-decoration: none; color: white; border-radius: 3px; margin-right: 5px; } .btn-tambah { background: #27ae60; padding: 10px 20px; display: inline-block; } .btn-edit { background: #f39c12; } .btn-hapus { background: #c0392b; } img { width: 50px; height: auto; object-fit: cover; } </style> </head> <body> <h2>Kelola Data Fasilitas</h2> <a href="tambah_fasilitas.php" class="btn btn-tambah">+ Tambah Fasilitas</a> <a href="index.php" style="margin-left: 10px; text-decoration: none;">Dashboard</a> <table> <thead> <tr> <th>No</th> <th>Gambar</th> <th>Nama Fasilitas</th> <th>Deskripsi</th> <th>Aksi</th> </tr> </thead> <tbody> <?php $no = 1; $query = mysqli_query($conn, "SELECT * FROM fasilitas"); while ($row = mysqli_fetch_assoc($query)): ?> <tr> <td><?= $no++; ?></td> <td><?= $row['gambar'] ? '<img src="../uploads/'.$row['gambar'].'">' : '-'; ?></td> <td><?= htmlspecialchars($row['nama_fasilitas']); ?></td> <td><?= substr(htmlspecialchars($row['deskripsi']), 0, 50); ?>...</td> <td> <a href="edit_fasilitas.php?id=<?= $row['id']; ?>" class="btn btn-edit">Edit</a> <a href="fasilitas.php?hapus=<?= $row['id']; ?>" class="btn btn-hapus" onclick="return confirm('Hapus?')">Hapus</a> </td> </tr> <?php endwhile; ?> </tbody> </table> </body> </html>