-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgetPOIs.php
63 lines (58 loc) · 1.72 KB
/
getPOIs.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
<?php
$con = mysql_connect("localhost","root","root");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("db", $con);
$results = mysql_query("
SELECT
dfuw_posts.ID AS pid,
dfuw_posts.post_title AS title,
dfuw_postmeta.meta_key AS mkey,
dfuw_postmeta.post_id AS pmid,
dfuw_postmeta.meta_value AS mval
FROM
dfuw_posts
INNER JOIN
dfuw_postmeta ON dfuw_posts.ID = dfuw_postmeta.post_id
WHERE
dfuw_posts.post_type = 'poi'
AND
dfuw_posts.post_status = 'publish'
AND
dfuw_postmeta.meta_key IN ('_poi_loc' ,'_poi_level' ,'_poi_type')");
$jsary = ["pois" => []];
$lastPid = 0;
$currentPid = 0;
$title = "";
$ifff = 0;
$elss = 0;
while($row = mysql_fetch_array($results))
{
$currentPid = $row['pid'];
$title = $row['title'];
$cmd = $row['mkey'];
$cmt = $row['mval'];
if($lastPid != $currentPid)
{
$insAry = [];
$insAry = ["title"=> $title, $cmd => $cmt];
array_push($jsary["pois"], $insAry);
$lastPid = $currentPid;
$ifff = $ifff + 1;
$currentPid = 0;
}
else
{
$ind = 0;
if($ifff > 0)
{
$ind = $ifff-1;
}
$insAry = [$cmd => $cmt];
$jsary["pois"][$ind][$cmd] = $cmt;
}
}
echo json_encode($jsary);
?>