| Server IP : 172.67.187.206 / Your IP : 172.71.28.156 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 : /Inetpub/www/training/group/ |
Upload File : |
<?php
include("../session.php");
// ตรวจสอบสิทธิ์
if ($role != 'group') {
header("Location: ../index.php");
exit;
}
// ดำเนินการลบวิชา (ถ้ามี)
if (isset($_GET['del'])) {
$id = intval($_GET['del']);
mysqli_query($conn, "DELETE FROM subjects WHERE id = $id AND group_id = $user_id");
header("Location: subjects.php");
exit;
}
// ดึงข้อมูลวิชาของกลุ่มนี้เท่านั้น
$result = mysqli_query($conn, "SELECT * FROM subjects WHERE group_id = $user_id 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">จัดการวิชา - <?php echo htmlspecialchars($group_name); ?></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 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>