Advertisement
Guest User

Untitled

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