-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstudentreport.php
More file actions
95 lines (80 loc) · 2.92 KB
/
studentreport.php
File metadata and controls
95 lines (80 loc) · 2.92 KB
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
<html>
<head>
<title>Class Statistics</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">
<link rel="stylesheet" href="new.css">
</head>
<?php
session_start();
$mysqli = new mysqli("localhost", "cs340", "cs340_s19", "courseeval");
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
echo "Please try again.";
}
$instructors = $mysqli->query("select fname, lname from instructor order by lname;");
?>
<div id="nav"><a href="http://34.73.123.138/"><button type="button" class="btn btn-default" >Home</button></a></div>
<div class="container">
<body>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">
<div class="form-group">
<h2 for="enterStudentID">Please select an instructor to continue:</h2>
<select class="form-control" id="selectinstructor" name="instructor">
<?php
if ($instructors->num_rows == 0){
echo 'Error: no instructors found.';
} else {
$instructors->data_seek(0);
while ($row = $instructors->fetch_assoc()) {
echo '<option>';
echo $row["lname"] . ', ' . $row["fname"];
echo '</option>';
}
}
?>
</select>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
<br><br>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
session_start();
$_SESSION["instructor"] = $_POST["instructor"];
$name = explode(', ', $_POST["instructor"]);
$fname = $name[1];
$lname = $name[0];
$_SESSION["fname"] = $fname;
$_SESSION["lname"] = $lname;
$classes = $mysqli->query("select distinct(course_name) from instructor, teaches, class
where fname='$fname' and lname='$lname'
and instructor.instructorid = teaches.instructorid
and teaches.class_num = class.class_num;");
echo '
<h2> Instructor: ' . $lname . ', ' . $fname . '</h2>
<h2>Select a class to see statistics:</h2>
<form action="studentstatistics.php" method="post">
<div class="form-group">
<select class="form-control" id="select" name="class">
';
if ($classes->num_rows == 0){
echo 'Error: no classes found!';
} else {
$classes->data_seek(0);
while ($row = $classes->fetch_assoc()){
echo '<option>';
echo $row["course_name"];
echo '</option>';
}
}
echo '
</select>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>';
}
session_write_close();
?>
</body>
</div>
</html>