<?php
$sql="select * from wx_zimi ";
$res=$dbs->query($sql);
$arr=array();
while($o=$dbs->fetch_object($res)){
$arr[]=$o;
}
//print_r($arr);die;
$now = date("D, d M Y H:i:s T");
$output = "<?xml version="1.0"?>
<rss version="2.0">
<channel>
<title>Our Demo RSS</title>
<link>http://www.tracypeterson.com/RSS/RSS.php</link>
<description>A Test RSS</description>
<language>en-us</language>
<pubDate>$now</pubDate>
<lastBuildDate>$now</lastBuildDate>
<docs>http://someurl.com</docs>
<managingEditor>you@youremail.com</managingEditor>
<webMaster>you@youremail.com</webMaster>
";
foreach ($arr as $line)
{
$output .= "<item><title>".$line->main."</title>
<link>".$line->jieguo."</link>
<description>".$line->id."</description>
</item>";
}
$output .= "</channel></rss>";
echo $output;
?>
转载自:https://www.ibm.com/developerworks/cn/xml/x-phprss/