real_escape_string($course);
#turn that course id number into an integer
$course = intval($course);
# let's see if that course even exists
$query = "SELECT * FROM Classes Where ID=" . $course;
#echo "
".$query."
";
$result2 = $link->query($query);
$row2 = $result2->fetch_assoc();
//notice this query and the results are result2 and row2 used later
if(!$result2) {
echo "
bad query
";
}
elseif ($result2->num_rows > 0) {
echo " This class id appears in the classes table!
";
}
else {
echo " This class id does not appear to exist - trouble will ensue - ERROR!";
echo "
********** ERROR ***********
";
}
#let's find all the students who are in that class so we can list them by name.
$query = "SELECT * FROM Attending JOIN (Students) ON (Attending.Student_id = Students.ID) Where Class_ID=" . $course;
#echo "
".$query."
";
$result = $link->query($query);
if(!$result) {
echo "
bad query
";
}
else {
echo " This class appears " . $result->num_rows . " times in the Students Table.";
if($result->num_rows == 0){
echo " There are no students in "; //opened, close later
}
else {
echo " Students who are in: "; //every open h3 needs a close
}
//first let's output the class - this came from the first query
echo $row2['Dept'] . ' ' . $row2['Number'] . '-' . $row2['Sec'] . ' : ';
echo $row2['Name'];
echo "
"; //closes either the if or the else starting h3
//now let's output all the students in that class
echo "";
while($row = $result->fetch_assoc()) {
echo "- ";
echo $row['First'] . ' ' . $row['Last'];
}
echo "
";
}
$link->close();
?>
Reset the Whole DB
Display All
List Course
Forms for Inserting New Data