-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApi.php
More file actions
40 lines (38 loc) · 998 Bytes
/
Api.php
File metadata and controls
40 lines (38 loc) · 998 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
// DB credentials.
define('DB_HOST','localhost');
define('DB_USER','root');
define('DB_PASS','');
define('DB_NAME','where_i_am');
$conn = new mysqli(DB_HOST,DB_USER,DB_PASS,DB_NAME);
$query1 = $conn->prepare("SET NAMES UTF8");
$query1->execute();
if(mysqli_connect_errno()){
die('Enable te connect to database'.mysql_connect_error());
}
$query = $conn->prepare("SELECT id_emp, name, description,lat, lng, type,image FROM emplacement;");
$query->execute();
$query->bind_result($id_emp, $name, $description,$lat,$lng ,$type,$image);
$department = array();
while($query->fetch()){
$temp = array();
$temp['id_emp'] = $id_emp;
$temp['name'] = $name;
$temp['description'] = $description;
$temp['type'] = $type;
$temp['lat'] = $lat;
$temp['lng'] = $lng;
$temp['image'] = $image;
array_push($department, $temp);
}
echo json_encode($department);
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
</head>
<body>
</body>
</html>