-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathfindFriend.php
More file actions
40 lines (35 loc) · 964 Bytes
/
findFriend.php
File metadata and controls
40 lines (35 loc) · 964 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
include ("init.php");
if($_SERVER['REQUEST_METHOD']=="POST"){
$messages=array();
$response=array();
$sql = "SELECT * FROM alumnus WHERE 1 ";
if(isset($_POST["branch"])){
$branch = clean($_POST["branch"]);
if($branch != "All"){
$sql = $sql. "AND `department` = '".$branch."' ";
}
}
if(isset($_POST["graduation_year"])){
$graduation_year = clean($_POST["graduation_year"]);
$sql = $sql."AND `graduation_year` = '".$graduation_year."' ";
}
if(isset($_POST["name"])){
$name = escape(clean($_POST["name"]));
$sql = $sql . " AND (`first_name` LIKE '%".$name."%' OR last_name LIKE '%".$name."%') ";
}
$result=query($sql);
if(row_count($result)>0){
$status = 200;
while($row = fetch_array($result)) {
$messages[] = $row;
}
}else{
$status = 400;
$messages[] = "No Result Found";
}
$response["status"] = $status;
$response["messages"] = $messages;
echo json_encode($response);
}
?>