/admin_selectTable.php

https://github.com/loboda/cs411 · PHP · 571 lines · 397 code · 163 blank · 11 comment · 44 complexity · 23283b9ebc3bfa1dba76651c04732975 MD5 · raw file

  1. <?php
  2. include 'includes/mysqlAdminLoginAssignment.php';
  3. $table=$_GET["table"];
  4. $query = "SELECT * FROM " . $table;
  5. /*
  6. ************************************************************
  7. * 'assignments_users_uiuc' tables
  8. ************************************************************
  9. */
  10. if ($table == "users")
  11. {
  12. // Change database
  13. $users_uiucDB = "assignments_users_uiuc";
  14. mysql_select_db($users_uiucDB) or die("Cannot connect to assignments_uiuc database.");
  15. $query = "SELECT * FROM `" . $table ."`";
  16. $result = mysql_query($query) or die(mysql_error());
  17. ?>
  18. <button type="insertAutomarkingButton" onclick="showInsert('users')">Insert New User</button>
  19. <br />
  20. <br />
  21. <?php
  22. echo "<table border='1'>
  23. <tr>
  24. <th>Username</th>
  25. <th>Password</th>
  26. <th>UserType</th>
  27. </tr>";
  28. while ($row = mysql_fetch_array($result))
  29. {
  30. echo "<tr>";
  31. echo "<td>" . $row['Username'] . "</td>";
  32. echo "<td>" . $row['Password'] . "</td>";
  33. echo "<td>" . $row['UserType'] . "</td>";
  34. ?>
  35. <td>
  36. <button type="editButton" onclick="showEdit('users', '<?php print($row['Username']); ?>', '0', '0' )">Edit</button>
  37. </td>
  38. <td>
  39. <button type="deleteButton" onclick="showDelete('users', '<?php print($row['Username']); ?>', '0', '0' )">Delete</button>
  40. </td>
  41. <?php
  42. echo "</tr>";
  43. }
  44. echo "</table>";
  45. }
  46. /*
  47. ************************************************************
  48. * 'assignments_uiuc' tables
  49. ************************************************************
  50. */
  51. $query = "SELECT * FROM `" . $table ."`";
  52. $result = mysql_query($query) or die(mysql_error());
  53. if ($table == "assignment")
  54. {
  55. ?>
  56. <button type="insertAssnButton" onclick="showInsert('assignment')">Insert New Assignment</button>
  57. <br />
  58. <br />
  59. <?php
  60. echo "<table border='1'>
  61. <tr>
  62. <th>AssnID</th>
  63. <th>AssnName</th>
  64. <th>GroupWork</th>
  65. <th>MaxMark</th>
  66. <th>AvgMark</th>
  67. <th>MedianMark</th>
  68. <th>CourseID</th>
  69. <th>DueTime</th>
  70. </tr>";
  71. while ($row = mysql_fetch_array($result))
  72. {
  73. echo "<tr>";
  74. echo "<td>" . $row['AssnID'] . "</td>";
  75. echo "<td>" . $row['AssnName'] . "</td>";
  76. echo "<td>" . $row['GroupWork'] . "</td>";
  77. echo "<td>" . $row['MaxMark'] . "</td>";
  78. echo "<td>" . $row['AvgMark'] . "</td>";
  79. echo "<td>" . $row['MedianMark'] . "</td>";
  80. echo "<td>" . $row['CourseID'] . "</td>";
  81. echo "<td>" . $row['DueTime'] . "</td>";
  82. ?>
  83. <td>
  84. <button type="editButton" onclick="showEdit('assignment', '<?php print($row['AssnID']); ?>', '0', '0' )">Edit</button>
  85. </td>
  86. <td>
  87. <button type="deleteButton" onclick="showDelete('assignment', '<?php print($row['AssnID']); ?>', '0', '0' )">Delete</button>
  88. </td>
  89. <?php
  90. echo "</tr>";
  91. }
  92. echo "</table>";
  93. }
  94. else if ($table == "automarking")
  95. {
  96. ?>
  97. <button type="insertAutomarkingButton" onclick="showInsert('automarking')">Insert New Automark</button>
  98. <br />
  99. <br />
  100. <?php
  101. echo "<table border='1'>
  102. <tr>
  103. <th>AutomarkID</th>
  104. <th>SampleSoln</th>
  105. <th>Configs</th>
  106. <th>AssnID</th>
  107. </tr>";
  108. while ($row = mysql_fetch_array($result))
  109. {
  110. echo "<tr>";
  111. echo "<td>" . $row['AutomarkID'] . "</td>";
  112. echo "<td>" . $row['SampleSoln'] . "</td>";
  113. echo "<td>" . $row['Configs'] . "</td>";
  114. echo "<td>" . $row['AssnID'] . "</td>";
  115. ?>
  116. <td>
  117. <button type="editButton" onclick="showEdit('automarking', '<?php print($row['AutomarkID']); ?>', '0', '0' )">Edit</button>
  118. </td>
  119. <td>
  120. <button type="deleteButton" onclick="showDelete('automarking', '<?php print($row['AutomarkID']); ?>', '0', '0' )">Delete</button>
  121. </td>
  122. <?php
  123. echo "</tr>";
  124. }
  125. echo "</table>";
  126. }
  127. else if ($table == "course")
  128. {
  129. ?>
  130. <button type="insertCourseButton" onclick="showInsert('course')">Insert New Course</button>
  131. <br />
  132. <br />
  133. <?php
  134. echo "<table border='1'>
  135. <tr>
  136. <th>CourseID</th>
  137. <th>CourseName</th>
  138. <th>SemesterName</th>
  139. </tr>";
  140. while ($row = mysql_fetch_array($result))
  141. {
  142. echo "<tr>";
  143. echo "<td>" . $row['CourseID'] . "</td>";
  144. echo "<td>" . $row['CourseName'] . "</td>";
  145. echo "<td>" . $row['SemesterName'] . "</td>";
  146. ?>
  147. <td>
  148. <button type="editButton" onclick="showEdit('course', '<?php print($row['CourseID']); ?>', '0', '0' )">Edit</button>
  149. </td>
  150. <td>
  151. <button type="deleteButton" onclick="showDelete('course', '<?php print($row['CourseID']); ?>', '0', '0' )">Delete</button>
  152. </td>
  153. <?php
  154. echo "</tr>";
  155. }
  156. echo "</table>";
  157. }
  158. else if ($table == "group")
  159. {
  160. ?>
  161. <button type="insertGroupButton" onclick="showInsert('group')">Insert New Group</button>
  162. <br />
  163. <br />
  164. <?php
  165. echo "<table border='1'>
  166. <tr>
  167. <th>GroupName</th>
  168. <th>AssnID</th>
  169. </tr>";
  170. while ($row = mysql_fetch_array($result))
  171. {
  172. echo "<tr>";
  173. echo "<td>" . $row['GroupName'] . "</td>";
  174. echo "<td>" . $row['AssnID'] . "</td>";
  175. ?>
  176. <td>
  177. <button type="editButton" onclick="showEdit('group', '<?php print($row['GroupName'])?>', '<?php print($row['AssnID'])?>', '0' )">Edit</button>
  178. </td>
  179. <td>
  180. <button type="deleteButton" onclick="showDelete('group', '<?php print($row['GroupName'])?>', '<?php print($row['AssnID'])?>', '0' )">Delete</button>
  181. </td>
  182. <?php
  183. echo "</tr>";
  184. }
  185. echo "</table>";
  186. }
  187. if ($table == "instructor")
  188. {
  189. ?>
  190. <button type="insertInstructorButton" onclick="showInsert('instructor')">Insert New Instructor</button>
  191. <br />
  192. <br />
  193. <?php
  194. echo "<table border='1'>
  195. <tr>
  196. <th>InstructorID</th>
  197. <th>FirstName</th>
  198. <th>LastName</th>
  199. <th>PhoneNumber</th>
  200. <th>OfficeLocation</th>
  201. <th>Email</th>
  202. </tr>";
  203. while ($row = mysql_fetch_array($result))
  204. {
  205. echo "<tr>";
  206. echo "<td>" . $row['InstructorID'] . "</td>";
  207. echo "<td>" . $row['FirstName'] . "</td>";
  208. echo "<td>" . $row['LastName'] . "</td>";
  209. echo "<td>" . $row['PhoneNumber'] . "</td>";
  210. echo "<td>" . $row['OfficeLocation'] . "</td>";
  211. echo "<td>" . $row['Email'] . "</td>";
  212. ?>
  213. <td>
  214. <button type="editButton" onclick="showEdit('instructor', '<?php print($row['InstructorID']); ?>', '0', '0' )">Edit</button>
  215. </td>
  216. <td>
  217. <button type="deleteButton" onclick="showDelete('instructor', '<?php print($row['InstructorID']); ?>', '0', '0' )">Delete</button>
  218. </td>
  219. <?php
  220. echo "</tr>";
  221. }
  222. echo "</table>";
  223. }
  224. if ($table == "memberof")
  225. {
  226. ?>
  227. <button type="insertInstructorButton" onclick="showInsert('memberof')">Insert New Group Member</button>
  228. <br />
  229. <br />
  230. <?php
  231. echo "<table border='1'>
  232. <tr>
  233. <th>GroupName</th>
  234. <th>StudentID</th>
  235. <th>AssnID</th>
  236. </tr>";
  237. while ($row = mysql_fetch_array($result))
  238. {
  239. echo "<tr>";
  240. echo "<td>" . $row['GroupName'] . "</td>";
  241. echo "<td>" . $row['StudentID'] . "</td>";
  242. echo "<td>" . $row['AssnID'] . "</td>";
  243. ?>
  244. <td>
  245. <button type="editButton" onclick="showEdit('memberof', '<?php print($row['GroupName']); ?>', '<?php print($row['StudentID']); ?>', '<?php print($row['AssnID']); ?>' )">Edit</button>
  246. </td>
  247. <td>
  248. <button type="deleteButton" onclick="showDelete('memberof', '<?php print($row['GroupName']); ?>', '<?php print($row['StudentID']); ?>', '<?php print($row['AssnID']); ?>' )">Delete</button>
  249. </td>
  250. <?php
  251. echo "</tr>";
  252. }
  253. echo "</table>";
  254. }
  255. else if ($table == "questions")
  256. {
  257. ?>
  258. <button type="insertAutomarkingButton" onclick="showInsert('questions')">Insert New Question</button>
  259. <br />
  260. <br />
  261. <?php
  262. echo "<table border='1'>
  263. <tr>
  264. <th>QuestionID</th>
  265. <th>QuestionName</th>
  266. <th>FullMark</th>
  267. <th>AssnID</th>
  268. </tr>";
  269. while ($row = mysql_fetch_array($result))
  270. {
  271. echo "<tr>";
  272. echo "<td>" . $row['QuestionID'] . "</td>";
  273. echo "<td>" . $row['QuestionName'] . "</td>";
  274. echo "<td>" . $row['FullMark'] . "</td>";
  275. echo "<td>" . $row['AssnID'] . "</td>";
  276. ?>
  277. <td>
  278. <button type="editButton" onclick="showEdit('questions', '<?php print($row['QuestionID']); ?>', '0', '0' )">Edit</button>
  279. </td>
  280. <td>
  281. <button type="deleteButton" onclick="showDelete('questions', '<?php print($row['QuestionID']); ?>', '0', '0' )">Delete</button>
  282. </td>
  283. <?php
  284. echo "</tr>";
  285. }
  286. echo "</table>";
  287. }
  288. else if ($table == "student")
  289. {
  290. ?>
  291. <button type="insertAutomarkingButton" onclick="showInsert('student')">Insert New Student</button>
  292. <br />
  293. <br />
  294. <?php
  295. echo "<table border='1'>
  296. <tr>
  297. <th>StudentID</th>
  298. <th>Major</th>
  299. <th>LastName</th>
  300. <th>FirstName</th>
  301. </tr>";
  302. while ($row = mysql_fetch_array($result))
  303. {
  304. echo "<tr>";
  305. echo "<td>" . $row['StudentID'] . "</td>";
  306. echo "<td>" . $row['Major'] . "</td>";
  307. echo "<td>" . $row['LastName'] . "</td>";
  308. echo "<td>" . $row['FirstName'] . "</td>";
  309. ?>
  310. <td>
  311. <button type="editButton" onclick="showEdit('student', '<?php print($row['StudentID']); ?>', '0', '0' )">Edit</button>
  312. </td>
  313. <td>
  314. <button type="deleteButton" onclick="showDelete('student', '<?php print($row['StudentID']); ?>', '0', '0' )">Delete</button>
  315. </td>
  316. <?php
  317. echo "</tr>";
  318. }
  319. echo "</table>";
  320. }
  321. else if ($table == "submission")
  322. {
  323. ?>
  324. <br />
  325. <br />
  326. <?php
  327. echo "<table border='1'>
  328. <tr>
  329. <th>AssnID</th>
  330. <th>Student</th>
  331. <th>Files</th>
  332. <th>AssnFinalMark</th>
  333. <th>Timestamp</th>
  334. </tr>";
  335. while ($row = mysql_fetch_array($result))
  336. {
  337. echo "<tr>";
  338. echo "<td>" . $row['AssnID'] . "</td>";
  339. echo "<td>" . $row['StudentID'] . "</td>";
  340. echo "<td>" . $row['Files'] . "</td>";
  341. echo "<td>" . $row['AssnFinalMark'] . "</td>";
  342. echo "<td>" . $row['Timestamp'] . "</td>";
  343. echo "</tr>";
  344. }
  345. echo "</table>";
  346. }
  347. else if ($table == "takes")
  348. {
  349. ?>
  350. <button type="insertAutomarkingButton" onclick="showInsert('takes')">Insert New Takes Relation</button>
  351. <br />
  352. <br />
  353. <?php
  354. echo "<table border='1'>
  355. <tr>
  356. <th>StudentID</th>
  357. <th>CourseID</th>
  358. <th>FinalMark</th>
  359. </tr>";
  360. while ($row = mysql_fetch_array($result))
  361. {
  362. echo "<tr>";
  363. echo "<td>" . $row['StudentID'] . "</td>";
  364. echo "<td>" . $row['CourseID'] . "</td>";
  365. echo "<td>" . $row['FinalMark'] . "</td>";
  366. ?>
  367. <td>
  368. <button type="editButton" onclick="showEdit('takes', '<?php print($row['StudentID']); ?>', '<?php print($row['CourseID']); ?>', '0' )">Edit</button>
  369. </td>
  370. <td>
  371. <button type="deleteButton" onclick="showDelete('takes', '<?php print($row['StudentID']); ?>', '<?php print($row['CourseID']); ?>', '0' )">Delete</button>
  372. </td>
  373. <?php
  374. echo "</tr>";
  375. }
  376. echo "</table>";
  377. }
  378. else if ($table == "teaches")
  379. {
  380. ?>
  381. <button type="insertAutomarkingButton" onclick="showInsert('teaches')">Insert New Teaches Relation</button>
  382. <br />
  383. <br />
  384. <?php
  385. echo "<table border='1'>
  386. <tr>
  387. <th>InstructorID</th>
  388. <th>CourseID</th>
  389. </tr>";
  390. while ($row = mysql_fetch_array($result))
  391. {
  392. echo "<tr>";
  393. echo "<td>" . $row['InstructorID'] . "</td>";
  394. echo "<td>" . $row['CourseID'] . "</td>";
  395. ?>
  396. <td>
  397. <button type="editButton" onclick="showEdit('teaches', '<?php print($row['InstructorID']); ?>', '<?php print($row['CourseID']); ?>', '0' )">Edit</button>
  398. </td>
  399. <td>
  400. <button type="deleteButton" onclick="showDelete('teaches', '<?php print($row['InstructorID']); ?>', '<?php print($row['CourseID']); ?>', '0' )">Delete</button>
  401. </td>
  402. <?php
  403. echo "</tr>";
  404. }
  405. echo "</table>";
  406. }
  407. mysql_close($mysqlConnection);
  408. ?>