-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstudent.php
99 lines (77 loc) · 2.25 KB
/
student.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
$servername = "ecsmysql";
$username = "cs332t15";
$password = "Oaj2chea";
$mydb = "mariadb";
// username and password need to be replaced by your username and password
// $link = mysql_connect('ecsmysql', 'username', 'password');
$link = mysql_connect($servername, $username, $password, $mydb);
if (!$link)
{
die('Could not connect: ' . mysql_error());
}
echo "successfully connect";
mysql_select_db($username,$link);
$stu_id = $_POST["student_cwid"];
//use SQL SELECT to query data
$sql = "SELECT course_title, enroll_grade
FROM Enrollment, Course, Section, Student
WHERE stu_cwid = enroll_stu_cwid AND enroll_section_id = section_id
AND section_course_id = course_id AND enroll_stu_cwid = '$stu_id'";
$result = mysql_query($sql,$link);
if (!$result) {
echo "Could not successfully run query ($sql) from DB: " . mysql_error();
exit;
}
if (mysql_num_rows($result) == 0) {
echo "No data found, nothing to print";
exit;
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container-fluid bg-success text-center">
<h3>Student Enrollment Grades</h3>
</div>
<div class="container-fluid text-center">
<table class="table table-striped table-bordered">
<thead>
<tr class="info text-center">
<th>Course Title</th>
<th>Grade</th>
</tr>
</thead>
<tbody>
<?php
while($row = mysql_fetch_assoc($result))
{
?>
<tr>
<td><?php echo $row["course_title"];?></td>
<td><?php echo $row["enroll_grade"];?></td>
</tr>
<?php } ?>
</tbody>
</table>
<div class="text-center">
<button type="button" class="btn btn-primary" onclick="goBack()">Go Back</button>
</div>
<script>
function goBack() {
window.history.back();
}
</script>
</div>
</body>
</html>
<?php
mysql_close($link);
?>