php - Passing formatted HTML code from SQL database to HTML page -
i have sql database passing data html page using method link here:
downloadurl("phpsqlajax_genxml.php", function(data) { var xml = data.responsexml; var markers = xml.documentelement.getelementsbytagname("marker"); (var = 0; < markers.length; i++) { var name = markers[i].getattribute("name"); var address = markers[i].getattribute("address"); var type = markers[i].getattribute("type"); var point = new google.maps.latlng( parsefloat(markers[i].getattribute("lat")), parsefloat(markers[i].getattribute("lng"))); var html = "<b>" + name + "</b> <br/>" + address; var icon = customicons[type] || {}; var marker = new google.maps.marker({ map: map, position: point, icon: icon.icon, shadow: icon.shadow }); bindinfowindow(marker, map, infowindow, html); }`enter code here` });
editing html in part fine if pass formatted html e.g. <b> hello world </b>
variable, display "<b> hello world </b>
" , not taken html code.
i want can pass preformatted html infowindow.
is way round this?
i solved this, instead of using following in php file create xml:
// iterate through rows, printing xml nodes each while ($row = @mysql_fetch_assoc($result)){ // add xml document node echo '<marker '; echo 'name="' . parsetoxml($row['name']) . '" '; echo 'address="' . parsetoxml($row['address']) . '" '; echo 'lat="' . $row['lat'] . '" '; echo 'lng="' . $row['lng'] . '" '; echo 'type="' . $row['type'] . '" '; echo '/>'; }
i used dom xml functions:
// iterate through rows, adding xml nodes each while ($row = @mysql_fetch_assoc($result)){ // add xml document node $node = $doc->create_element("marker"); $newnode = $parnode->append_child($node); $newnode->set_attribute("name", $row['name']); $newnode->set_attribute("address", $row['address']); $newnode->set_attribute("lat", $row['lat']); $newnode->set_attribute("lng", $row['lng']); $newnode->set_attribute("type", $row['type']); }
both versions shown here