/public_html/attendance/select_course.php

https://github.com/sorabji52/capstone · PHP · 164 lines · 110 code · 22 blank · 32 comment · 17 complexity · a6a1d16b321b2191559aa13ff98ac4fa MD5 · raw file

  1. <?php
  2. include('../util.php');
  3. include('../header.php');
  4. $link = connect();
  5. //////////////TO SUBMIT NEW ATTENDANCE RECORDS
  6. if (isset($_POST['submit_course_new'])) {
  7. //declaring variables to use when 'submit_course_new' is pressed
  8. $course_nums = $_POST['course_nums'];
  9. $sections = $_POST['sections'];
  10. if( is_array($course_nums)){
  11. while (list ($key, $val) = each ($course_nums)) {
  12. $cn = $val;
  13. echo "$val <br />";
  14. if( is_array($sections)){
  15. while (list ($key, $val) = each ($sections)) {
  16. $sx = $val;
  17. echo "$val <br />";
  18. }
  19. $resource = "SELECT people.last_name, people.first_name, students.id as stud_string_id, students.student_id as stud_num_id, sections.id, sections.sec, sections.course_id
  20. FROM people, students, sections
  21. INNER JOIN absences
  22. WHERE sections.id = absences.fk_absent_section
  23. AND people.id = students.student_id
  24. AND absences.fk_absent_section = students.sec_id
  25. AND sections.course_id = '$cn' AND sections.sec = '$sx'
  26. GROUP BY students.student_id
  27. ORDER BY people.last_name, people.first_name";
  28. $_SESSION['attendance_resource'] = $resource;
  29. header('Location: '.$root.'attendance/record_new.php');
  30. }else
  31. echo "";
  32. //$section_id = $_GET['sec'];
  33. }
  34. }else
  35. echo "";
  36. }
  37. /////////////TO VIEW EXISTING RECORDS BY COURSE:
  38. else if (isset($_POST['submit_course_date_view'])) {
  39. //declaring variables to use when 'submit_course_view' is pressed
  40. $course_nums = $_POST['course_nums'];
  41. $sections = $_POST['sections'];
  42. /* $the_dates = $_POST['the_dates'];
  43. if( is_array($the_dates)){
  44. while (list ($key, $val) = each ($the_dates)) {
  45. $td = $val;
  46. echo "$val <br />";
  47. }
  48. }
  49. */
  50. if( is_array($course_nums)){
  51. while (list ($key, $val) = each ($course_nums)) {
  52. $cn = $val;
  53. echo "$val <br />";
  54. if( is_array($sections)){
  55. while (list ($key, $val) = each ($sections)) {
  56. $sx = $val;
  57. echo "$val <br />";
  58. }
  59. $e_resource = "SELECT people.last_name, people.first_name, students.id as stud_string_id, students.student_id as stud_num_id, sections.id, sections.sec, sections.course_id, absences.isAbsent, absences.isExcused, absences.the_date
  60. FROM people, students, sections
  61. INNER JOIN absences
  62. WHERE sections.id = absences.fk_absent_section
  63. AND people.id = students.student_id
  64. AND absences.fk_absent_section = students.sec_id
  65. AND sections.course_id = '$cn' AND sections.sec = '$sx'
  66. AND absences.the_date = '$td'
  67. ORDER BY absences.the_date, people.last_name, people.first_name";
  68. $_SESSION['attendance_resource'] = $e_resource;
  69. header('Location: '.$root.'attendance/view_by_course.php');
  70. }else
  71. echo "";
  72. //$section_id = $_GET['sec'];
  73. }
  74. }else
  75. echo "";
  76. }
  77. ////////////
  78. /////////////TO VIEW EXISTING RECORDS BY STUDENT:
  79. else if (isset($_POST['submit_course_stud_view'])) {
  80. //declaring variables to use when 'submit_course_view' is pressed
  81. $course_nums = $_POST['course_nums'];
  82. $sections = $_POST['sections'];
  83. /* $the_dates = $_POST['the_dates'];
  84. if( is_array($the_dates)){
  85. while (list ($key, $val) = each ($the_dates)) {
  86. $td = $val;
  87. echo "$val <br />";
  88. }
  89. }
  90. */
  91. if( is_array($course_nums)){
  92. while (list ($key, $val) = each ($course_nums)) {
  93. $cn = $val;
  94. echo "$val <br />";
  95. if( is_array($sections)){
  96. while (list ($key, $val) = each ($sections)) {
  97. $sx = $val;
  98. echo "$val <br />";
  99. }
  100. $e_resource = "SELECT people.last_name, people.first_name, students.id as stud_string_id, students.student_id as stud_num_id, sections.id, sections.sec, sections.course_id, absences.isAbsent, absences.isExcused, absences.the_date
  101. FROM people, students, sections
  102. INNER JOIN absences
  103. WHERE sections.id = absences.fk_absent_section
  104. AND people.id = students.student_id
  105. AND absences.fk_absent_section = students.sec_id
  106. AND sections.course_id = '$cn' AND sections.sec = '$sx'
  107. AND absences.the_date = '$td'
  108. ORDER BY absences.the_date, people.last_name, people.first_name";
  109. $_SESSION['attendance_resource'] = $e_resource;
  110. header('Location: '.$root.'attendance/view_by_student.php');
  111. }else
  112. echo "";
  113. //$section_id = $_GET['sec'];
  114. }
  115. }else
  116. echo "";
  117. }
  118. //////////////
  119. else
  120. echo "";
  121. //
  122. echo '<center><div width=\"450px\"><h3>Select a course and section.</h3>';
  123. echo '<Form Name ="form_select_course" Method ="post" ACTION = "select_course.php">';
  124. //Drop-Down form, Group By courses
  125. $qry = mysql_query("SELECT course_id FROM sections GROUP BY course_id");
  126. echo '<select name="course_nums[]"><option value="">Course</option>';
  127. while($dat = mysql_fetch_assoc($qry))
  128. echo '<option value="' . $dat['course_id'] . '">' . $dat['course_id'] . '</option>';
  129. echo'</select>&nbsp;&nbsp;';
  130. //Drop-Down form, Group By sections
  131. $qry = mysql_query("SELECT sec FROM sections GROUP BY sec");
  132. echo '<select name="sections[]"><option value="">Section</option>';
  133. while($dat = mysql_fetch_assoc($qry))
  134. echo '<option value="' . $dat['sec'] . '">' . $dat['sec'] . '</option>';
  135. echo'</select><br />
  136. <br />';
  137. echo '<input type = "Submit" name = "submit_course_new" value = "Enter Attendance for This Class"><br /><br />';
  138. echo '<input type = "Submit" name = "submit_course_date_view" value = "View Records for This Class by Date"><br /><br />';
  139. echo '<input type = "Submit" name = "submit_course_stud_view" value = "View Records From This Class by Student"></form></div></center>';
  140. ?>