I would like to hyperlink my url data in popup, where user can click those website. However, it did not work.
Below is my source code:
if ($rowCount > 0) {
//Array for JSON output
$rows = array();
//Get the SQL results
while($row = $result->fetch_array()){
$fid = $row["Id"];
$Name = $row["Name"];
$address = $row["address"];
$Star = $row["Star"];
$latitude = $row["latitude"];
$longitude = $row["longitude"];
$hp = $row["hp"];
$url = $row["url"];
$rows[] = array(
"fid" => $fid,
"Name" => $Name,
"address" => $address,
"Star" => $Star,
"latitude" => $latitude,
"longitude" => $longitude,
"hp" => $hp,
"url" => $url
);
}
echo "var dataPOIs = ";
//Output to JSON format
echo json_encode($rows, JSON_NUMERIC_CHECK);
echo ";\n";
echo '
for (var i=0; i<dataPOIs.length; i++){
L.marker([dataPOIs[i].latitude, dataPOIs[i].longitude],{icon: createIcon(), title:dataPOIs[i].Name}).bindPopup("Name: " + " " + "<b>" + dataPOIs[i].Name + "</b>" + "</br>" + "</br>" + "Star: " + "<b>" + dataPOIs[i].Star + "</b>" + "</br>" + "</br>" + "Address: " + " " + "<b>" + dataPOIs[i].address + "</b>" + "</br>" + "</br>" + "Hp: " + " " + "<b>" + dataPOIs[i].hp + "</b>" + "</br>" + "</br>" + "Website: " + " " + "<a href='" + dataPOIs[i].url + "'>" + "</a>").addTo(pois);
}
';
}
It shows
Parse error: syntax error, unexpected '" + dataPOIs[i].url + "' (T_CONSTANT_ENCAPSED_STRING), expecting ';' or ','
in Popup line