当前位置: 动力学知识库 > 问答 > 编程问答 >

Display Value From Sqlite Database In An XML Format Using PHP

问题描述:

I have the following code:

 <?php

$url1=$_SERVER['REQUEST_URI'];

header("Refresh: 600; URL=$url1;");

header("Content-type: text/xml");

try

{

$db = new PDO("sqlite:/bigdb.sql");

$result = $db->query('SELECT "value" FROM event_log AS t1 JOIN (SELECT MAX("time") AS max_time FROM event_log WHERE "eid" = 7) AS t2 ON t1."time" = t2.max_time WHERE t1."eid" = 7');

$xml_output = '<?xml version=\"1.0\"?>\n';

$xml_output .= "<entries>\n";

foreach($result as $row)

{

$xml_output .= "\t<entry>\n";

$xml_output .= "\t\t<WarmIn>" . $row['value'] . "</WarmIn>\n";

$xml_output .= "\t</entry>\n";

}

$xml_output .= "</entries>";

$db = null;

}

catch(PDOException $e)

{

echo 'Exception : '.$e->getMessage();

}

?>

This doesn't show any values, however, if I want to display the data only as a plain text, without XML, it works, but now, leaving it as it is, the page is simply blank, no errors.

Any suggestions?

分享给朋友:
您可能感兴趣的文章:
随机阅读: