Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions database/connect.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
$server = 'localhost:3306';
$user = 'root';
$pass = '';
$database = 'web_pka';

$connect = new mysqli(
$server,
$user,
$pass,
$database
);

if ($connect) {
mysqli_query($connect, "SET NAMES 'utf8' ");
echo "success";
} else {
echo "error";
}

?>
55 changes: 55 additions & 0 deletions database/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<h1>Danh mục sinh viên đăng ký môn học</h1>
<style>
table {
width: 100%;
border-collapse: collapse;
}

table,
th,
td {
border: 1px solid black;
padding: 8px;
}
</style>
<table style="border: 1;">
<tr>
<th>MSSV</th>
<th>Họ tên</th>
<th>Kỳ</th>
<th>Đăng ký</th>
</tr>
<?php
$server = 'localhost:3306';
$user = 'root';
$pass = '';
$database = 'web_pka';
$conn = new mysqli($server, $user, $pass, $database);
// Kiểm tra kết nối
if ($conn->connect_error) {
die("Kết nối CSDL thất bại: " . $conn->connect_error);
}
$sql = "SELECT sinhvien.MSSV, sinhvien.HoTen, monhoc.MaMH, monhoc.TenMH, dangky.Ky
FROM dangky
JOIN sinhvien ON dangky.MSSV = sinhvien.MSSV
JOIN monhoc ON dangky.MaMH = monhoc.MaMH;";
$result = $conn->query($sql);
if ($result) {
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
echo "<tr>";
echo "<td>" . $row["MSSV"] . "</td>";
echo "<td>" . $row["HoTen"] . "</td>";
echo "<td>" . $row["Ky"] . "</td>";
echo "<td>" . $row["TenMH"] . "</td>";
echo "</tr>";
}
} else {
echo "<tr><td colspan='5'>Không có dữ liệu</td></tr>";
}
} else {
echo "Error: " . $conn->error;
}
$conn->close();
?>
</table>