使用PHP以XML格式显示Sqlite数据库的值

时间:2016-09-30 10:16:28

标签: php xml sqlite

我有以下代码:

    <?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();
}

?>

这并没有显示任何值,但是,如果我只想将数据显示为纯文本,没有XML,它可以工作,但现在,保持原样,页面只是空白,没有错误。

有什么建议吗?

0 个答案:

没有答案