-
Notifications
You must be signed in to change notification settings - Fork 27
/
generate-data.php
130 lines (130 loc) · 5.37 KB
/
generate-data.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
include('configdb.php');
//============================================================= all map data =======================
//fetch table rows from mysql db
$sql = "SELECT id_wisata, lat, lng, kategori AS category, wisata, keterangan, fasilitas, alamat, pic
FROM wisata AS w INNER JOIN kategori_wisata AS kw
ON w.id_kategori = kw.id_kategori
ORDER BY id_wisata";
$result = mysqli_query($connection, $sql) or die("Error in Selecting " . mysqli_error($connection));
//create an array
$emparray[] = array();
while($row =mysqli_fetch_assoc($result)){
$emparray[] = $row;
}
//write to json file
$fp = fopen('data/data-semua.json', 'w');
fwrite($fp, json_encode($emparray));
fclose($fp);
//============================================================= event map data =====================
$sql = "SELECT id_event, lat, lng, event, keterangan, fasilitas, alamat, pic
FROM event
ORDER BY id_event";
$result = mysqli_query($connection, $sql) or die("Error in Selecting " . mysqli_error($connection));
//create an array
$emparray1[] = array();
while($row =mysqli_fetch_assoc($result)){
$emparray1[] = $row;
}
//write to json file
$fp = fopen('data/data-event.json', 'w');
fwrite($fp, json_encode($emparray1));
fclose($fp);
//========================================================= wisata kuliner map data ================
$sql = "SELECT id_wisata, kategori AS category, lat, lng, wisata, keterangan, fasilitas, alamat, pic
FROM wisata AS w INNER JOIN kategori_wisata AS kw
ON w.id_kategori = kw.id_kategori
WHERE kw.id_kategori = 3
ORDER BY id_wisata";
$result = mysqli_query($connection, $sql) or die("Error in Selecting " . mysqli_error($connection));
//create an array
$emparray2[] = array();
while($row =mysqli_fetch_assoc($result)){
$emparray2[] = $row;
}
//write to json file
$fp = fopen('data/data-wisata-kuliner.json', 'w');
fwrite($fp, json_encode($emparray2));
fclose($fp);
//========================================================== wisata religi map data ================
$sql = "SELECT id_wisata, kategori AS category, lat, lng, wisata, keterangan, fasilitas, alamat, pic
FROM wisata AS w INNER JOIN kategori_wisata AS kw
ON w.id_kategori = kw.id_kategori
WHERE kw.id_kategori = 4
ORDER BY id_wisata";
$result = mysqli_query($connection, $sql) or die("Error in Selecting " . mysqli_error($connection));
//create an array
$emparray3[] = array();
while($row =mysqli_fetch_assoc($result)){
$emparray3[] = $row;
}
//write to json file
$fp = fopen('data/data-wisata-religi.json', 'w');
fwrite($fp, json_encode($emparray3));
fclose($fp);
//============================================================ wisata alam map data ================
$sql = "SELECT id_wisata, kategori AS category, lat, lng, wisata, keterangan, fasilitas, alamat, pic
FROM wisata AS w INNER JOIN kategori_wisata AS kw
ON w.id_kategori = kw.id_kategori
WHERE kw.id_kategori = 5
ORDER BY id_wisata";
$result = mysqli_query($connection, $sql) or die("Error in Selecting " . mysqli_error($connection));
//create an array
$emparray4[] = array();
while($row =mysqli_fetch_assoc($result)){
$emparray4[] = $row;
}
//write to json file
$fp = fopen('data/data-wisata-alam.json', 'w');
fwrite($fp, json_encode($emparray4));
fclose($fp);
//========================================================== wisata sejarah map data ===============
$sql = "SELECT id_wisata, kategori AS category, lat, lng, wisata, keterangan, fasilitas, alamat, pic
FROM wisata AS w INNER JOIN kategori_wisata AS kw
ON w.id_kategori = kw.id_kategori
WHERE kw.id_kategori = 6
ORDER BY id_wisata";
$result = mysqli_query($connection, $sql) or die("Error in Selecting " . mysqli_error($connection));
//create an array
$emparray5[] = array();
while($row =mysqli_fetch_assoc($result)){
$emparray5[] = $row;
}
//write to json file
$fp = fopen('data/data-wisata-sejarah.json', 'w');
fwrite($fp, json_encode($emparray5));
fclose($fp);
//=========================================================== wisata buatan map data ===============
$sql = "SELECT id_wisata, kategori AS category, lat, lng, wisata, keterangan, fasilitas, alamat, pic
FROM wisata AS w INNER JOIN kategori_wisata AS kw
ON w.id_kategori = kw.id_kategori
WHERE kw.id_kategori = 7
ORDER BY id_wisata";
$result = mysqli_query($connection, $sql) or die("Error in Selecting " . mysqli_error($connection));
//create an array
$emparray6[] = array();
while($row =mysqli_fetch_assoc($result)){
$emparray6[] = $row;
}
//write to json file
$fp = fopen('data/data-wisata-buatan.json', 'w');
fwrite($fp, json_encode($emparray6));
fclose($fp);
//=========================================================== wisata buatan map data ===============
/*$sql = "SELECT id_wisata, kategori AS category, lat, lng, wisata, keterangan, alamat, pic
FROM wisata AS w INNER JOIN kategori_wisata AS kw
ON w.id_kategori = kw.id_kategori
WHERE kw.id_kategori = 8
ORDER BY id_wisata";
$result = mysqli_query($connection, $sql) or die("Error in Selecting " . mysqli_error($connection));
//create an array
$emparray7[] = array();
while($row =mysqli_fetch_assoc($result)){
$emparray7[] = $row;
}
//write to json file
$fp = fopen('data/data-fasilitas.json', 'w');
fwrite($fp, json_encode($emparray7));
fclose($fp);*/
//==================================================================================================
?>