-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearchEvent.php
65 lines (43 loc) · 1.55 KB
/
searchEvent.php
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
session_start();
include_once('db_connections/connection_db.php');
include_once('db_function/db_func.php');
$connect = db_connect();
/* if($_GET){
if($_GET['action'] == 'getEvent') {
$get_query = "SELECT * from event";
$res_query = mysqli_query($connect,$get_query);
$msg = array();
while($row=mysqli_fetch_array($res_query)){
array_push($msg,array('id' =>$row['event_id'],'image' => $row['event_image'],'name'=>$row['event_name'],'date' => $row['date'], 'status' => $row['status']));
}
echo json_encode(array('msg' => $msg));
//write to json file
/* $fp = fopen('data.json', 'w');
fwrite($fp, json_encode(array('msg' => $msg)));
fclose($fp);
exit;
}
} */
$name = _sqlReal($_POST['name']);
$get_query = "SELECT event_id,event_image,event_name,date,status,venue from event WHERE event_name like '%".$name."' OR event_name like '".$name."%' ORDER BY event_id DESC";
$data = '';
$res_query = mysqli_query($connect,$get_query);
while($row=mysqli_fetch_array($res_query)){
$id = $row['event_id'];
$image = $row['event_image'];
$name = $row['event_name'];
$date = $row['date'];
$status = $row['status'];
$venue = $row['venue'];
$data .= $id.'|'.$image.'|'.$name.'|'.$date.'|'.$status.'|'.$venue.'||';
}
echo $data;
exit;
function fail($message) {
die(json_encode(array('status' => 'fail', 'message' => $message)));
}
function success($message) {
die(json_encode(array('status' => 'success', 'message' => $message)));
}
?>