-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquery.php
46 lines (36 loc) · 1.29 KB
/
query.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>query.php</title>
<style>
table, th, td{
border: 1px solid black;
border-collapse: collapse;
}
</style>
</head>
<body>
<table>
<tr>
<th>รหัสนักศึกษา</th>
<th>ชื่อนักศึกษา</th>
<th>ชื่อคณะที่นักศึกษาสังกัด</th>
<th>รหัสวิชาเรียน</th>
<th>ชื่อวิชาเรียน</th>
</tr>
<?php
$conn = new PDO("mysql:host=localhost;dbname=curriculum;charset=utf8", "root", "");
$sql = ("SELECT student.id, student.name, student.facid, subjects.id, subjects.name, faculty.name FROM student
INNER JOIN subjects ON (student.id = subjects.student_id)
INNER JOIN faculty ON (student.facid = faculty.id) ORDER BY student.id");
$result = $conn->query($sql);
while($row = $result->fetch()){
echo "<tr><td> $row[0] </td><td> $row[1] </td><td> $row[5] </td><td> $row[3] </td><td> $row[4] </td></tr>";
}
$conn = null;
?>
</table>
</body>
</html>