-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquery1a.php
More file actions
25 lines (21 loc) · 881 Bytes
/
Copy pathquery1a.php
File metadata and controls
25 lines (21 loc) · 881 Bytes
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
<?php
$conn=mysqli_connect("db.soic.indiana.edu","i308s17_team87","my+sql=i308s17_team87", "i308s17_team87");
// Check connection
if (!$conn)
{die("Failed to connect to MySQL: " . mysqli_connect_error()); }
else
{ echo "Established Database Connection" ;}
$section = mysqli_real_escape_string($conn, $_POST['section']);
$sql = "SELECT s.studentID as studentID, concat(s.lname, ' ',s.fname) as name, sec.sectionID as section_ID FROM student as s, section as sec, grade as g Where sec.sectionID = '$section' and g.studentID = s.studentID and g.sectionID = sec.sectionID ORDER BY name asc;";
$result = mysqli_query($conn,$sql);
if (mysqli_num_rows($result) > 0) {
echo "<table><tr><th>Student</th></tr>";
while($row = mysqli_fetch_assoc($result)) {
echo "<tr><td>".$row["name"]. "</td></tr>";
}
echo "</table>";
} else {
echo "0 results";
}
mysqli_close($conn);
?>