Gnu -> Det virker ikke, desværre, den viser koden i browseren i stedet for at sende filen som jeg kunne se den gjorde hvis jeg havde angivet en værdi som den skulle hente..
Koden ser sådan her ud pt:
<?
$sql = "SELECT * FROM tagwall WHERE Id='". $_GET['userid'] ."' ORDER BY Dato DESC";
$result = mysql_query($sql, $conn) or die (mysql_error());
// SimpleXMLElement er guf: [p"]http://dk.php.net/manual/da/ref.simplexml.php[/url]
$xml = new SimpleXMLElement('<guestbook></guestbook>');
$posts = $xml->addChild('posts');
while($newArray = mysql_fetch_array($result)) {
$post = $posts->addChild('post');
$post->addChild('id',$newArray['Id']);
$post->addChild('nr',$newArray['Nr']);
$post->addChild('fra_id',$newArray['Fra']);
$post->addChild('fra_nick',$newArray['Fra_nick']);
$post->addChild('dato',$newArray['Dato']);
$post->addChild('text',$newArray['Text']);
}
// Headers til browseren
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private',false);
header('Content-Type: application/force-download');
header('Content-Disposition: attachment; filename="guestbook.xml";');
// Indhold til filen
print $xml->asXML();
// Dø script!
die();
?>
og den viser alle data fra tabellen..
Har osse prøvet:
<?
$sql = "SELECT * FROM tagwall WHERE Id='". $_GET['userid'] ."' ORDER BY Dato DESC";
$result = mysql_query($sql, $conn) or die (mysql_error());
// SimpleXMLElement er guf: [p"]http://dk.php.net/manual/da/ref.simplexml.php[/url]
$xml = new SimpleXMLElement('<guestbook></guestbook>');
$posts = $xml->addChild('posts');
while($newArray == mysql_fetch_assoc($result)) {
$post = $posts->addChild('post');
$post->addChild('id',$newArray['Id']);
$post->addChild('nr',$newArray['Nr']);
$post->addChild('fra_id',$newArray['Fra']);
$post->addChild('fra_nick',$newArray['Fra_nick']);
$post->addChild('dato',$newArray['Dato']);
$post->addChild('text',$newArray['Text']);
}
// Headers til browseren
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private',false);
header('Content-Type: application/force-download');
header('Content-Disposition: attachment; filename="guestbook.xml";');
// Indhold til filen
print $xml->asXML();
// Dø script!
die();
?>
Indlæg senest redigeret d. 13.08.2007 01:10 af Bruger #6586