prepare("SELECT id, name FROM tracks WHERE user_id=? ORDER BY id DESC"); $query->bind_param('i', $userid); $query->execute(); $query->bind_result($trackid, $trackname); header("Content-type: text/xml"); $xml = new XMLWriter(); $xml->openURI("php://output"); $xml->startDocument("1.0"); $xml->setIndent(true); $xml->startElement('root'); while ($query->fetch()) { $xml->startElement("track"); $xml->writeElement("trackid", $trackid); $xml->writeElement("trackname", $trackname); $xml->endElement(); } $xml->endElement(); $xml->endDocument(); $xml->flush(); $query->free_result(); } $mysqli->close(); ?>