Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(!empty($_POST['id']) && isset($_POST['id'])) {
- header("Location: ?m=search.results&id=".$_POST['id']."");
- } elseif(!empty($_POST['major']) && isset($_POST['major'])) {
- header("Location: ?m=search.results&major=".$_POST['major']."");
- } elseif(!empty($_POST['college']) && isset($_POST['major'])) {
- header("Location: ?m=search.results&college=".$_POST['college']."");
- } elseif (!empty($_POST['name']) && isset($_POST['name'])) {
- //if(preg_match("/^[ a-zA-Z]+/", $_POST['name'])){
- // $name=$_POST['name'];
- header("Location: ?m=search.results&name=".$_POST['name']."");
- } elseif (!empty($_POST['id']) && !empty($_POST['college']) && !empty($_POST['major']) && isset($_POST['submit']) && !empty($_POST['name'])) {
- echo "<div class='alert alert-danger'>No students found. Please try different parameters.</div>";
- }
- ?>
- <h4>Search</h4>
- <form method="POST">
- <table width="100%">
- <tr><td>ID:</td><td> <input type="text" name="id" class="form-control"></textarea></td></tr>
- <tr><td>Name:</td><td> <input type="text" name="name" class="form-control"></textarea></td></tr>
- <tr><td>Major:</td><td><select name="major" class="form-control"><option></option><?php echo majorSelect(); ?></select></td></tr>
- <tr><td>College:</td><td><select name="college" class="form-control"><option></option><?php echo collegeSelect(); ?></select></td></tr>
- <tr><td colspan="2"><input type="submit" name="submit" value="Search" class="btn btn-lrg btn-primary" style="margin-top:10px;"></td></tr>
- </table>
- </form>
- <!-- If major is set -->
- <?php if(isset($_GET['id'])){
- ?>
- <?php
- $students = $db->query("SELECT * FROM `user_details` a, `user` b WHERE a.uid = b.id AND a.uid = '".$_GET['id']."'");
- while($student = $students->fetch()) {
- echo '
- <tr>
- <td>'.$student['uid'].'</td>
- <td>'.$student['name'].'</td>
- <td>'.$student['major'].'</td>
- <td>'.$student['college'].'</td>
- <td><a href="?m=profile&id='.$student['id'].'" style="display:block">View</a></td>
- </tr>';
- }
- ?>
- <!-- If major is set -->
- <?php } elseif(isset($_GET['major'])){ ?>
- <?php
- $students = $db->query("SELECT * FROM `user_details` a, `user` b WHERE a.uid = b.id AND a.major = '".$_GET['major']."'");
- while($student = $students->fetch()) {
- echo '
- <tr>
- <td>'.$student['uid'].'</td>
- <td>'.$student['name'].'</td>
- <td>'.$student['major'].'</td>
- <td>'.$student['college'].'</td>
- <td><a href="?m=profile&id='.$student['id'].'" style="display:block">View</a></td>
- </tr>';
- }
- ?>
- <!-- If college is set -->
- <?php } elseif(isset($_GET['college'])){ ?>
- <?php
- $students = $db->query("SELECT * FROM `user_details` a, `user` b WHERE a.uid = b.id AND a.college = '".$_GET['college']."'");
- while($student = $students->fetch()) {
- echo '
- <tr>
- <td>'.$student['uid'].'</td>
- <td>'.$student['name'].'</td>
- <td>'.$student['major'].'</td>
- <td>'.$student['college'].'</td>
- <td><a href="?m=profile&id='.$student['id'].'" style="display:block">View</a></td>
- </tr>';
- }
- ?>
- <!-- If name is set -->
- <?php } elseif(isset($_GET['name'])){ ?>
- <?php
- $name = $_GET['name'];
- $students = $db->query("SELECT * FROM `user_details` a, `user` b WHERE a.uid = b.id AND b.name LIKE '%". $name . "%'");
- while($student = $students->fetch()) {
- echo '
- <tr>
- <td>'.$student['uid'].'</td>
- <td>'.$student['name'].'</td>
- <td>'.$student['major'].'</td>
- <td>'.$student['college'].'</td>
- <td><a href="?m=profile&id='.$student['id'].'" style="display:block">View</a></td>
- </tr>';
- }
- ?>
- <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement