-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path9b.php
More file actions
40 lines (30 loc) · 1.08 KB
/
Copy path9b.php
File metadata and controls
40 lines (30 loc) · 1.08 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
<?php
$conn=mysqli_connect("db.soic.indiana.edu","i308s18_team30","my+sql=i308s18_team30", "i308s18_team30");
// Check connection
if (!$conn)
{die("Failed to connect to MySQL: " . mysqli_connect_error()); }
else
{ echo "Established Database Connection" ;}
$majorid= mysqli_real_escape_string($conn,$_POST['major']);
$sql="SELECT CONCAT(s.FirstName,' ',s.LastName) AS Name
FROM Course AS c, Major AS m, Student AS s, Section AS sec, Students_taking_courses as stc
WHERE m.MajorID = s.MajorID
AND s.MajorID = c.MajorID
AND stc.StudentID = s.StudentID
AND m.GraduationReq <= (SELECT SUM(CreditHrs) FROM Course as c, Students_taking_courses as stc, Student as s
WHERE stc.SectionID = c.SectionID AND s.StudentID =stc.StudentID)
AND s.MajorID = $majorid
GROUP BY Name;";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "<table border='1'><tr><th>Name</th></tr>";
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<tr><td>".$row["Name"]."</td></tr>";
}
echo "</table>";
} else {
echo "0 results";
}
mysqli_close($conn);
?>