The entire "departments-simple.php"
<!DOCTYPE html>
<html>
<head>
<title>Departments</title>
<link rel="stylesheet" href="site.css" type="text/css"/>
</head>
<body>
<h1>Faculty of Arts & Sciences</h1>
<h2>Departments</h2>
<?php
// Connecting, selecting database
$mysqli = new mysqli('localhost','class','cscie12','coursecatalog');
if ($mysqli->connect_errno) {
echo "Failed to connect to mysql: ".$mysqli->connect_errno." ".$mysqli->connect_error;
}
// Performing SQL query
$query = 'SELECT distinct department_short, department_code FROM courses order by department_short';
$result = $mysqli->query($query);
// iterating through results
echo "<ul>\n";
while ($row = $result->fetch_assoc()) {
echo "<li>";
echo $row['department_short'];
echo "</li>\n";
}
echo "</ul>\n";
// Free resultset
$result->free();
// Close connection
$mysqli->close();
?>
</body>
</html>