Advertisement
Guest User

Untitled

a guest
Jan 17th, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.81 KB | None | 0 0
  1. <?php
  2. session_start();
  3. include "dbFunctions.php";
  4. IF (isset($_SESSION['parent_nric'])){
  5. $theNRIC = $_SESSION['parent_nric'];
  6.  
  7. $redirectQuery = "SELECT * "
  8. . "FROM student, parent, student_cca "
  9. . "WHERE student.student_id = student_cca.student_id "
  10. . "AND student.parent_nric = parent.parent_nric "
  11. . "AND parent.parent_nric ='".$theNRIC."'";
  12. $redirectResult = mysqli_query($link, $redirectQuery) or die(mysql_error());
  13. $totalrows = mysqli_num_rows($redirectResult);
  14. if ($totalrows > 0)
  15. { // has results
  16. header("Location: parent_view_cca.php");
  17. exit(0);
  18. }
  19. else
  20. { // no result
  21. echo "<h4>Welcome to Maintain CCA!</h4>";
  22. }
  23.  
  24. $query = "SELECT student.student_id, cca.cca_name, cca_category.category_name FROM choices, student, parent, cca, cca_category WHERE student.student_id = choices.student_id and choices.cca_id=cca.cca_id AND cca.category_id=cca_category.category_id and student.parent_nric = parent.parent_nric and parent.parent_nric='".$theNRIC."'";
  25. $result = mysqli_query($link, $query);
  26. $numrow = mysqli_num_rows($result);
  27. if ($numrow > 0)
  28. { // has results
  29. echo "<h5>Please check your choices accordingly.</h5>";
  30. }
  31. else
  32. { // no result
  33. //echo "<h4>You have not chosen a CCA! <a href='parent_add_submit_cca_choice.php'>Click here to do so!</a>.</h4>";
  34. header("Location: parent_add_submit_cca_choice.php");
  35. exit(0);
  36. }
  37. $row = mysqli_fetch_array($result);
  38. ?>
  39.  
  40. <!DOCTYPE html>
  41. <html lang="en">
  42.  
  43. <head>
  44.  
  45. <meta charset="utf-8">
  46. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  47. <meta name="viewport" content="width=device-width, initial-scale=1">
  48. <meta name="description" content="">
  49. <meta name="author" content="">
  50.  
  51. <title>CCA Registration System</title>
  52.  
  53. <!-- Bootstrap Core CSS -->
  54. <link href="css/bootstrap.min.css" rel="stylesheet">
  55.  
  56. <!-- Custom CSS -->
  57. <link href="css/shop-homepage.css" rel="stylesheet">
  58. <script language="javascript" type="text/javascript">
  59. function showCCADropDown1() {
  60. var str1 = document.getElementById("category1").value;
  61. if (window.XMLHttpRequest) {
  62. // code for IE7+, Firefox, Chrome, Opera, Safari
  63. xmlhttp = new XMLHttpRequest();
  64. } else {
  65. // code for IE6, IE5
  66. xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  67. }
  68. xmlhttp.onreadystatechange = function () {
  69. if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
  70. document.getElementById("ajaxDiv1").innerHTML = xmlhttp.responseText;
  71. }
  72. };
  73. xmlhttp.open("GET", "getCCADropDown.php?cat_id=" + str1, true);
  74. xmlhttp.send();
  75. }
  76. function showCCADropDown2() {
  77. var str2 = document.getElementById("category2").value;
  78. if (window.XMLHttpRequest) {
  79. // code for IE7+, Firefox, Chrome, Opera, Safari
  80. xmlhttp = new XMLHttpRequest();
  81. } else {
  82. // code for IE6, IE5
  83. xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  84. }
  85. xmlhttp.onreadystatechange = function () {
  86. if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
  87. document.getElementById("ajaxDiv2").innerHTML = xmlhttp.responseText;
  88. }
  89. };
  90. xmlhttp.open("GET", "getCCADropDown.php?cat_id=" + str2, true);
  91. xmlhttp.send();
  92. }
  93. </script>
  94.  
  95. <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  96. <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  97. <!--[if lt IE 9]>
  98. <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
  99. <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
  100. <![endif]-->
  101.  
  102. </head>
  103.  
  104. <body>
  105.  
  106. <!-- Navigation -->
  107. <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
  108. <div class="container">
  109. <!-- Brand and toggle get grouped for better mobile display -->
  110. <div class="navbar-header">
  111. <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
  112. <span class="sr-only">Toggle navigation</span>
  113. <span class="icon-bar"></span>
  114. <span class="icon-bar"></span>
  115. <span class="icon-bar"></span>
  116. </button>
  117. <a class="navbar-brand" href="#">CCA Registration System</a>
  118. </div>
  119. <!-- Collect the nav links, forms, and other content for toggling -->
  120. <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
  121. <ul class="nav navbar-nav">
  122. <li>
  123. <a href="#">Browse CCA</a>
  124. </li>
  125. <li>
  126. <a href="parent_cca_choice.php">CCA Choices</a>
  127. </li>
  128. <li>
  129. <a href="parent_edit_maintain_personal_information.php">Maintain Personal Information</a>
  130. </li>
  131. <li>
  132. <a href="parent_maintain_student_information.php">Maintain Student Information</a>
  133. </li>
  134. <li>
  135. <a href="logout.php">Logout</a>
  136. </li>
  137. </ul>
  138. </div>
  139. <!-- /.navbar-collapse -->
  140. </div><!-- /.container -->
  141. </nav>
  142. <center>
  143.  
  144. <!-- Page Content -->
  145. <h1><u>Maintain CCA</u></h1>
  146. <br>
  147. <form method="post" action="do_parent_submit_cca_choice.php">
  148. <div style="width:350px;">
  149. <h4><label for="choice">1st Choice:</label></h4>
  150. <br>
  151. <select class="form-control" id="choice" name="choice">
  152. <option value ="<?php echo $row['category_id']; ?>">
  153. <?php echo $row['category_name']; ?>
  154. </option>
  155. </select>
  156. <br>
  157. <select class="form-control" id="choice" name="choice">
  158. <option value ="<?php echo $row['cca_id']; ?>">
  159. <?php echo $row['cca_name']; ?>
  160. </option>
  161. </select>
  162. <br></br>
  163. <input type="hidden" name="student_id" value="<?php echo $row['student_id'] ?>" />
  164. <a href="do_parent_delete_cca_choice.php"<button type="button" class="btn btn-danger">Delete CCA Choices</button></a>
  165. <a href="do_parent_submit_cca_choice.php"<button type="button" class="btn btn-info">Submit CCA Choices</button></a>
  166. <br><br>
  167. <button id = 'hideshow' value='hide/show' type="button" class="btn btn-warning">Add CCA Choices</button>
  168. <br></br>
  169. <div id='content'>
  170. <div style="width:350px;">
  171. <label for="category1">2nd Choice:</label>
  172. <select class="form-control" id="category1" name="category1" onchange="showCCADropDown1()">
  173. <option value="0">All Category</option>
  174. <?php
  175. while ($categoryRow1 = mysqli_fetch_assoc($categoryResult1)) {
  176. ?>
  177. <option value ="<?php echo $categoryRow1['category_id']; ?>">
  178. <?php echo $categoryRow1['category_name']; ?>
  179. </option>
  180. <?php
  181. }
  182. ?>
  183. </select>
  184. <div id='ajaxDiv1'></div>
  185. </div>
  186. <br>
  187. <div class="row">
  188. <div style="width:350px;">
  189. <label for="category2">3rd Choice:</label>
  190. <select class="form-control" id="category2" name="category2" onchange="showCCADropDown2()">
  191. <option value="0">All Category</option>
  192. <?php
  193. while ($categoryRow2 = mysqli_fetch_assoc($categoryResult2)) {
  194. ?>
  195. <option value ="<?php echo $categoryRow2['category_id']; ?>">
  196. <?php echo $categoryRow2['category_name']; ?>
  197. </option>
  198. <?php
  199. }
  200. ?>
  201. </select>
  202. <div id='ajaxDiv2'></div>
  203. </div>
  204. </div>
  205. </div>
  206. </div>
  207. </form>
  208. <?php }else {
  209. echo"you are unable to view this page";
  210. }
  211. ?>
  212. <br>
  213. </centre>
  214.  
  215. <!-- Footer -->
  216. <footer>
  217. <div class="row">
  218. <div class="col-lg-12">
  219. <p>Copyright &copy; 4 Aces</p>
  220. </div>
  221. </div>
  222. </footer>
  223.  
  224. </div>
  225. <!-- /.container -->
  226.  
  227. <!-- jQuery -->
  228. <script src="js/jquery.js"></script>
  229. <script>
  230. jQuery(document).ready(function(){
  231. jQuery('#hideshow').live('click', function(event) {
  232. jQuery('#content').toggle('show');
  233. });
  234. });
  235. </script>
  236.  
  237. <!-- Bootstrap Core JavaScript -->
  238. <script src="js/bootstrap.min.js"></script>
  239.  
  240. </body>
  241.  
  242. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement