forked from mikailyusuf/foodie-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_restaurant_foods.php
65 lines (53 loc) · 1.67 KB
/
get_restaurant_foods.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
require_once('ConnectionLocal.php');
try {
$connecion = new ConnectionLocal();
$json_string = file_get_contents("php://input");
$data = json_decode($json_string, true);
$id = stripcslashes($data['id']);
$restaurant_id = mysqli_real_escape_string($connecion->connectToDb(), $id);
$query = "SELECT * FROM food_items WHERE restaurant_token = '$restaurant_id'";
$result = $connecion->connectToDb()->query($query);
if ($result->num_rows >= 1) {
$emparray = array();
while ($row = mysqli_fetch_assoc($result)) {
$emparray[] = $row;
}
echo json_encode($emparray);
}
} catch (Exception $e) {
http_response_code(401);
echo('Message: ' . $e->getMessage());
$message = json_encode(array("message" => $e->getMessage(), "status" => false));
echo $message;
}
//<?php
//include 'config.php';
//
//try{
//$json_string = file_get_contents( "php://input");
//$data = json_decode($json_string,true);
//
// $id=stripcslashes($data['id']);
// $restaurant_id = mysqli_real_escape_string($CONNECTION, $id);
//
//
// $sql = "SELECT * FROM foods WHERE restaurant_id = '$restaurant_id' ";
// $result = mysqli_query($CONNECTION, $sql);
//
// $emparray = array();
// while($row =mysqli_fetch_assoc($result))
// {
// $emparray[] = $row;
// }
//
// http_response_code(200);
// echo json_encode($emparray);
//
//}
//catch(Exception $e) {
// http_response_code(400);
// echo('Message: ' .$e->getMessage());
// $message = json_encode(array("message" => $e->getMessage(),"status" => false));
// echo $message;
// }