| Server IP : 172.67.187.206 / Your IP : 162.159.115.41 Web Server : Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/5.6.30 System : Windows NT WIN-ECQAAA40806 6.2 build 9200 (Windows Server 2012 Standard Edition) i586 User : SYSTEM ( 0) PHP Version : 5.6.30 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : E:/Inetpub/www/training/admin/ |
Upload File : |
<?php
include("../session.php");
// ตรวจสอบสิทธิ์
if ($role != 'admin') {
header("Location: ../index.php");
exit;
}
include("../db.php");
// ดำเนินการลบวิชา (ถ้ามี)
if (isset($_GET['del'])) {
$id = intval($_GET['del']);
mysqli_query($conn, "DELETE FROM subjects WHERE id = $id");
header("Location: subjects.php");
exit;
}
// ดึงข้อมูลวิชาทั้งหมด
$result = mysqli_query($conn, "SELECT * FROM subjects ORDER BY id DESC");
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>จัดการวิชา</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<h3 class="text-center">จัดการวิชา - ผู้ดูแลระบบ</h3>
<p class="text-right">
<a href="dashboard.php" class="btn btn-default btn-sm">← กลับหน้าหลัก</a>
<a href="subject_form.php" class="btn btn-primary btn-sm">+ เพิ่มวิชา</a>
</p>
<table class="table table-bordered">
<thead>
<tr>
<th>#</th>
<th>ชื่อวิชา</th>
<th>หลักสูตรปี</th>
<th>เปอร์เซ็นต์ผ่าน (%)</th>
<th>จัดการ</th>
</tr>
</thead>
<tbody>
<?php
$i = 1;
while ($row = mysqli_fetch_assoc($result)):
?>
<tr>
<td><?php echo $i++; ?></td>
<td><?php echo htmlspecialchars($row['name']); ?></td>
<td><?php echo isset($row['curriculum_year']) ? htmlspecialchars($row['curriculum_year']) : '-'; ?></td>
<td><?php echo $row['pass_percentage']; ?>%</td>
<td>
<a href="subject_form.php?id=<?php echo $row['id']; ?>" class="btn btn-info btn-xs">แก้ไข</a>
<a href="?del=<?php echo $row['id']; ?>" class="btn btn-danger btn-xs"
onclick="return confirm('คุณแน่ใจว่าต้องการลบวิชานี้?')">ลบ</a>
<a href="questions.php?subject_id=<?php echo $row['id']; ?>" class="btn btn-success btn-xs">จัดการข้อสอบ</a>
</td>
</tr>
<?php endwhile; ?>
<?php if (mysqli_num_rows($result) == 0): ?>
<tr>
<td colspan="5" class="text-center">ยังไม่มีวิชา กรุณาเพิ่มวิชาใหม่</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
</body>
</html>