-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrequest_node.php
57 lines (39 loc) · 1.09 KB
/
request_node.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
<?php
// have $_GET[mode/keyword] from client request
require_once("db.php");
$con = openDB();
// Part 1/2: Get keyword's "nodeID", "nodeType", "mapID", "x", "y"
if ($_GET[keyword] == "") {
$arr["notExistOn"] = "keyword";
echo json_encode($arr);
mysql_close($con);
return;
}
$keyword = "%".str_ireplace(" ", "%", $_GET[keyword])."%";
$sql = "SELECT N.nodeID, N.nodeType, N.mapID, N.x, N.y
FROM location_node AS LN, node AS N
WHERE N.nodeID = LN.nodeID
AND LN.name LIKE '$keyword'";
$rows = doQuery($con, $sql);
if ($rows[0]["nodeID"] == null) {
$arr["notExistOn"] = "keyword";
echo json_encode($arr);
mysql_close($con);
return;
}
$arr["notExistOn"] = "null";
// Part 2/2: Return result
// Case 1/2: "mode" = "X"
if ($_GET[mode] == "X") {
$arr["nodeID"] = $rows[0]["nodeID"];
$arr["nodeType"] = $rows[0]["nodeType"];
$arr["mapID"] = $rows[0]["mapID"];
$arr["x"] = $rows[0]["x"];
$arr["y"] = $rows[0]["y"];
}
// Case 2/2: "mode" = "N"
if ($_GET[mode] == "N") {
}
echo json_encode($arr);
mysql_close($con);
?>