-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathitems.php
33 lines (26 loc) · 900 Bytes
/
items.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
<?php
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Methods: GET, POST");
header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, X-Token-Auth, Authorization");
require_once "config/db.php";
require_once "config/item.php";
$db = new DatabaseConnection();
$conn = $db->getConnection();
$query = "SELECT * FROM `food`";
$result = $conn->query($query);
if(!$result){
http_response_code(200);
echo json_encode("error");
die();
}
$items;
$counter = 0;
while($row = $result->fetch_assoc()){
$cur = new item($row["id"], $row["name"], $row["type"], $row["price"], $row["description"], $row["image"]);
$items[$counter++] = $cur;
// http_response_code(200);
// echo json_encode($cur);
}
http_response_code(200);
echo json_encode($items);
?>