-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddmarker.php
More file actions
30 lines (27 loc) · 898 Bytes
/
Copy pathaddmarker.php
File metadata and controls
30 lines (27 loc) · 898 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
<?php
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
require 'config/config.php';
$q=$_GET["q"];
try{
$conn=new PDO("mysql:host=$host;dbname=$db",$user,$pwd);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e){
echo "Connection failed: ". $e->getMessage();
}
$stmt = $conn->prepare("SELECT * FROM instimaps JOIN category ON category.cat_id=instimaps.cat_id WHERE category.category=:q");
$stmt->bindParam(':q',$q);
$stmt->execute();
$outp = "[";
while($rs = $stmt->fetch(PDO::FETCH_ASSOC)) {
if ($outp != "[") {$outp .= ",";}
$outp .= '{"room":"' . $rs["locname"] . '",';
$outp .= '"dept":"' . $rs["depname"] . '",';
$outp .= '"location":"'. $rs["locdescrip"] . '",';
$outp .= '"lat":"' . $rs["lat"] . '",';
$outp .= '"lng":"' . $rs["lng"] . '"}';
}
$outp .="]";
echo($outp);
?>