File: /var/www/w230/html/behavior/summary.php
<?php include 'db.php'; ?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>สรุปคะแนนรายคน</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Prompt&display=swap" rel="stylesheet">
</head>
<body style="font-family: 'Prompt', sans-serif;">
<div class="container mt-5">
<h3>สรุปคะแนนความประพฤติรายคน</h3>
<table class="table table-bordered">
<thead>
<tr><th>ชื่อนักเรียน</th><th>คะแนนที่ถูกตัดรวม</th></tr>
</thead>
<tbody>
<?php
$sql = "SELECT student_name, SUM(points) as total FROM behaviors GROUP BY student_name";
$result = mysqli_query($conn, $sql);
while ($row = mysqli_fetch_assoc($result)) {
echo "<tr><td>{$row['student_name']}</td><td>{$row['total']}</td></tr>";
}
?>
</tbody>
</table>
</div>
</body>
</html>