Advertisement
Guest User

Untitled

a guest
Mar 6th, 2015
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.59 KB | None | 0 0
  1. <?php
  2.  
  3. if(!empty($_POST['id']) && isset($_POST['id'])) {
  4.  
  5. header("Location: ?m=search.results&id=".$_POST['id']."");
  6.  
  7. } elseif(!empty($_POST['major']) && isset($_POST['major'])) {
  8.  
  9. header("Location: ?m=search.results&major=".$_POST['major']."");
  10.  
  11. } elseif(!empty($_POST['college']) && isset($_POST['major'])) {
  12.  
  13. header("Location: ?m=search.results&college=".$_POST['college']."");
  14.  
  15. } elseif (!empty($_POST['name']) && isset($_POST['name'])) {
  16.  
  17. //if(preg_match("/^[ a-zA-Z]+/", $_POST['name'])){
  18. // $name=$_POST['name'];
  19.  
  20. header("Location: ?m=search.results&name=".$_POST['name']."");
  21.  
  22.  
  23. } elseif (!empty($_POST['id']) && !empty($_POST['college']) && !empty($_POST['major']) && isset($_POST['submit']) && !empty($_POST['name'])) {
  24.  
  25. echo "<div class='alert alert-danger'>No students found. Please try different parameters.</div>";
  26.  
  27.  
  28.  
  29. }
  30.  
  31. ?>
  32.  
  33.  
  34. <h4>Search</h4>
  35.  
  36. <form method="POST">
  37. <table width="100%">
  38.  
  39.  
  40. <tr><td>ID:</td><td> <input type="text" name="id" class="form-control"></textarea></td></tr>
  41.  
  42. <tr><td>Name:</td><td> <input type="text" name="name" class="form-control"></textarea></td></tr>
  43.  
  44. <tr><td>Major:</td><td><select name="major" class="form-control"><option></option><?php echo majorSelect(); ?></select></td></tr>
  45.  
  46. <tr><td>College:</td><td><select name="college" class="form-control"><option></option><?php echo collegeSelect(); ?></select></td></tr>
  47.  
  48.  
  49. <tr><td colspan="2"><input type="submit" name="submit" value="Search" class="btn btn-lrg btn-primary" style="margin-top:10px;"></td></tr>
  50.  
  51. </table>
  52. </form>
  53.  
  54. <!-- If major is set -->
  55. <?php if(isset($_GET['id'])){
  56.  
  57.  
  58. ?>
  59.  
  60. <?php
  61.  
  62. $students = $db->query("SELECT * FROM `user_details` a, `user` b WHERE a.uid = b.id AND a.uid = '".$_GET['id']."'");
  63.  
  64.  
  65. while($student = $students->fetch()) {
  66.  
  67. echo '
  68. <tr>
  69. <td>'.$student['uid'].'</td>
  70. <td>'.$student['name'].'</td>
  71. <td>'.$student['major'].'</td>
  72. <td>'.$student['college'].'</td>
  73. <td><a href="?m=profile&id='.$student['id'].'" style="display:block">View</a></td>
  74.  
  75. </tr>';
  76.  
  77. }
  78.  
  79. ?>
  80.  
  81. <!-- If major is set -->
  82. <?php } elseif(isset($_GET['major'])){ ?>
  83.  
  84.  
  85.  
  86. <?php
  87.  
  88. $students = $db->query("SELECT * FROM `user_details` a, `user` b WHERE a.uid = b.id AND a.major = '".$_GET['major']."'");
  89.  
  90. while($student = $students->fetch()) {
  91.  
  92. echo '
  93. <tr>
  94. <td>'.$student['uid'].'</td>
  95. <td>'.$student['name'].'</td>
  96. <td>'.$student['major'].'</td>
  97. <td>'.$student['college'].'</td>
  98.  
  99. <td><a href="?m=profile&id='.$student['id'].'" style="display:block">View</a></td>
  100.  
  101. </tr>';
  102.  
  103. }
  104.  
  105.  
  106.  
  107. ?>
  108.  
  109.  
  110. <!-- If college is set -->
  111. <?php } elseif(isset($_GET['college'])){ ?>
  112.  
  113.  
  114.  
  115. <?php
  116.  
  117. $students = $db->query("SELECT * FROM `user_details` a, `user` b WHERE a.uid = b.id AND a.college = '".$_GET['college']."'");
  118.  
  119. while($student = $students->fetch()) {
  120.  
  121. echo '
  122. <tr>
  123. <td>'.$student['uid'].'</td>
  124. <td>'.$student['name'].'</td>
  125. <td>'.$student['major'].'</td>
  126. <td>'.$student['college'].'</td>
  127. <td><a href="?m=profile&id='.$student['id'].'" style="display:block">View</a></td>
  128.  
  129. </tr>';
  130.  
  131. }
  132.  
  133.  
  134.  
  135. ?>
  136.  
  137. <!-- If name is set -->
  138. <?php } elseif(isset($_GET['name'])){ ?>
  139.  
  140.  
  141.  
  142. <?php
  143.  
  144. $name = $_GET['name'];
  145.  
  146. $students = $db->query("SELECT * FROM `user_details` a, `user` b WHERE a.uid = b.id AND b.name LIKE '%". $name . "%'");
  147.  
  148. while($student = $students->fetch()) {
  149.  
  150. echo '
  151. <tr>
  152. <td>'.$student['uid'].'</td>
  153. <td>'.$student['name'].'</td>
  154. <td>'.$student['major'].'</td>
  155. <td>'.$student['college'].'</td>
  156. <td><a href="?m=profile&id='.$student['id'].'" style="display:block">View</a></td>
  157.  
  158. </tr>';
  159.  
  160. }
  161.  
  162.  
  163.  
  164. ?>
  165.  
  166.  
  167.  
  168. <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement