I am trying to write some data that I fetch from a db to the page with xml formatting but I cant get it to work,there no error or something, it just doesnt print anything, thats my code
if($_GET["action"]=="fetch"){ $sqlget = "select * from hotspot"; $result = $conn->query($sqlget); $writer = new XMLWriter(); $writer->openMemory(); $writer->startDocument('1.0','UTF-8'); $writer->setIndent(4); $writer->startElement('hotspots'); while ($row=$result->fetch_assoc()) { $lat=$row["lat"]; $lng=$row["lng"]; if(distanceGeoPoints($lat,$lng,$_GET["lat"],$_GET["lng"])<$_GET["range"]){ $writer->startElement('entry'); $writer->writeAttribute('lat',$row["lat"]); $writer->writeAttribute('lng',$row["lng"]); $writer->writeAttribute('ssid',$row["ssid"]); $writer->writeAttribute('name',$row["name"]); $writer->writeAttribute('password',$row["password"]); $writer->endElement(); echo $row["lat"].";".$row["lng"].";".$row["ssid"].";".$row["name"].";".$row["password"]; //->this gets echoed just fine } } $writer->endElement(); $writer->endDocument(); echo $writer->outputMemory(); //->this doesn't work $writer->flush(); }
No comments:
Post a Comment