-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathselect_store.php
More file actions
41 lines (35 loc) · 911 Bytes
/
select_store.php
File metadata and controls
41 lines (35 loc) · 911 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
41
<?php
include("./connection.php");
$items = [];
$return_data = array(
"store_data" => [],
);
$sql = "SELECT * FROM store";
$query = mysqli_query($connection, $sql);
while ($item = mysqli_fetch_assoc($query)) {
$items[] = $item;
}
for ($i = 0; $i < count($items); $i++) {
$image = '';
$file = $items[$i]['image'];
// echo $file;
$fp = fopen($file, 'r');
if (file_exists($file)) {
while (!feof($fp)) {
$image = $image . fgetc($fp);
}
fclose($fp);
}
$base64 = (base64_encode($image));
// echo $base64 . "</br>";
// var_dump($items);
$data = array(
"id" => $items[$i]['id'],
"name" => $items[$i]['name'],
"image" => $base64,
"address" => $items[$i]['address'],
"phone" => $items[$i]['phone']
);
array_push($return_data["store_data"], $data);
}
echo json_encode($return_data);