2016-12-07 21 views
-1

我需要輸入我的latlngs價值爲locations類似:與latlngs值多標記從數據庫

var locations = [ 
['Bondi Beach', -33.890542, 151.274856], 
['Coogee Beach', -33.923036, 151.259052], 
['Cronulla Beach', -34.028249, 151.157507]  
['Manly Beach', -33.80010128657071, 151.28747820854187], 
['Maroubra Beach', -33.950198, 151.259302] 
]; 

這是我的PHP代碼:

$result = $conn->query("select address, lat, lang from user where phoneno = '" . $phoneno. "'"); 

$outp = "["; 
while($rs = $result->fetch_array(MYSQLI_ASSOC)) { 
if ($outp != "[") {$outp .= ",";} 
$outp .= '{"address":' . $rs["address"] . ','; 
$outp .= '"lat":"' . $rs["lat"] . '",'; 
$outp .= '"lang":"' . $rs["lang"]  . '"}'; 
} 
$outp .="]"; 

而且這是在URL輸出值:

[{"address":Tampines Street 86, 
    Singapore,"lat":"1.3498584","lang":"103.9273744"}] 
+2

你可以請詳細說明您的問題 – Nitesh

+0

看一看@json_encode http://php.net/manual/en/function.json-encode.php –

+0

@Nitesh基本上我婉從我的PHP輸出調入我的HTML作爲var位置的值 – Xinee

回答

0

您需要從您的php中獲取這些值並填充wi瘦HTML。 Here is an sample.

+0

我似乎無法使它工作。它也需要在一個循環中 – Xinee

+0

該鏈接的示例在JavaScript中完成 – Xinee

相關問題