result.php
Code (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
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
<?php
//Maak een Database connectie
$db = mysql_connect("localhost","user","password");
if (!$db) {
die('Could not connect to db: ' . mysql_error());
}
//Selecteer de Database
mysql_select_db("database",$db);
//Vervang * in de query met de kollom namen.
$result = mysql_query("select * from markers", $db);
//Maak een array
$json_response = array();
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$row_array['id'] = $row['id'];
$row_array['name'] = $row['name'];
$row_array['address'] = $row['address'];
$row_array['lat'] = $row['lat'];
$row_array['lng'] = $row['lng'];
$row_array['type'] = $row['type'];
//push de waarde in de array
array_push($json_response,$row_array);
}
//Schrijf de output naar de JSON file
$json_data = json_encode($json_response);
file_put_contents('location.json', $json_data);
?>
//Maak een Database connectie
$db = mysql_connect("localhost","user","password");
if (!$db) {
die('Could not connect to db: ' . mysql_error());
}
//Selecteer de Database
mysql_select_db("database",$db);
//Vervang * in de query met de kollom namen.
$result = mysql_query("select * from markers", $db);
//Maak een array
$json_response = array();
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$row_array['id'] = $row['id'];
$row_array['name'] = $row['name'];
$row_array['address'] = $row['address'];
$row_array['lat'] = $row['lat'];
$row_array['lng'] = $row['lng'];
$row_array['type'] = $row['type'];
//push de waarde in de array
array_push($json_response,$row_array);
}
//Schrijf de output naar de JSON file
$json_data = json_encode($json_response);
file_put_contents('location.json', $json_data);
?>