subjectList.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. $root = $_SERVER['DOCUMENT_ROOT'];
  3. include($root . "/util/session.php"); //checks that the user is logged in
  4. include($root . "/util/privilege_check.php");
  5. checkPrivilege("admin");
  6. $degreeID = mysqli_real_escape_string($db, $_GET['degreeID']);
  7. $query = "SELECT * FROM subjects where degreeID='$degreeID'";
  8. $result = mysqli_query($db, $query);
  9. if (mysqli_num_rows($result) < 1) {
  10. header("Location: /admin/admin.php?msg=No Subjects");
  11. }
  12. ?>
  13. <!DOCTYPE html>
  14. <html lang="en">
  15. <head>
  16. <title>Subject List</title>
  17. <link rel="stylesheet" type="text/css" href="adminStyle.css">
  18. <link rel="stylesheet" type="text/css" href="tableStyle.css">
  19. </head>
  20. <?php
  21. include($root . "/admin/header.php");
  22. ?>
  23. <main>
  24. <body>
  25. <li><a href="/admin/degreeList.php">Back</a></li>
  26. <table border="1px" id="users">
  27. <thead>
  28. <tr>
  29. <th>Actions</th>
  30. <th>Subject ID</th>
  31. <th>Name</th>
  32. <th>Description</th>
  33. <th>Coordinator</th>
  34. </tr>
  35. </thead>
  36. <tbody>
  37. <?php //ugly php + html hybrid code that does stuff
  38. while ($row = mysqli_fetch_assoc($result)) { ?>
  39. <tr>
  40. <td>
  41. <a href="/admin/subjectMod.php?subjectID=<?php echo $row['subjectID'] ?>&&degreeID=<?php echo $row['degreeID'] ?>">Modify</a>
  42. <a href="/admin/subjectDel.php?subjectID=<?php echo $row['subjectID'] ?>&&degreeID=<?php echo $row['degreeID'] ?>">Delete</a>
  43. <a href="/admin/subjectsStudentsList.php?subjectID=<?php echo $row['subjectID'] ?>&&degreeID=<?php echo $row['degreeID'] ?>">List students</a>
  44. </td>
  45. <td><?php echo $row['subjectID']; ?>
  46. </td>
  47. <td><?php echo $row['subjectName']; ?></td>
  48. <td><?php echo $row['description']; ?></td>
  49. <td><?php echo $row['coordinatorID']; ?></td>
  50. </tr>
  51. <?php } ?>
  52. </tbody>
  53. </table>
  54. </body>
  55. </html>
  56. </main>
  57. <?php
  58. include($root . "/admin/footer.php");
  59. ?>