/ Published in: PHP

Stolen from the mentioned URL - this is used to make SPRY Framework work together with MYSQL.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// // Use of function: // // $qstring = "select * from TABLE"; // $result = mysql_query($qstring); // echo createXML_fromSQLResult($result); // // http://macdiggs.com/index.php/2006/07/05/integration-of-spry-and-phpmysql/ // function createXML_fromSQLResult(&$result, $containerName="container", $elementName="element", $encoding="Shift_JIS") { //this functions creates XML output from the SQL result. $xml = <<<EOF <?xml version="1.0" encoding="{$encoding}" ?> <{$containerName}> EOF; while ($stuff = mysql_fetch_assoc($result)) { $xml .= "<{$elementName} id=\"{$stuff[id]}\">"; foreach($stuff as $key=>$value) { $value = htmlspecialchars($value); $xml .= <<<EOF <{$key}>{$value}</{$key}>\n EOF; } $xml .= "</{$elementName}>\n"; } $xml .= <<<EOF </{$containerName}> EOF; return $xml; }
URL: http://macdiggs.com/index.php/2006/07/05/integration-of-spry-and-phpmysql/
Comments
