|
发表于 2011-8-15 11:35:20
|
显示全部楼层
PHP复制代码
<?php
$sql = "select * from is_haigui where status=1 order by created desc limit 5";
$query = $this->db->query($sql);
$result = $query->result_array();
$sql = "select * from is_photo where status=1 order by created desc limit 5";
$query = $this->db->query($sql);
$result1 = $query->result_array();
$sql = "select * from is_event where status=1 order by created desc limit 3";
$query = $this->db->query($sql);
$result2 = $query->result_array();
$sql = "select * from is_investment where status=1 order by created desc limit 1";
$query = $this->db->query($sql);
$result3 = $query->result_array();
$sql = "select * from is_job where status=1 order by created desc limit 1";
$query = $this->db->query($sql);
$result4 = $query->result_array();
$sql = "select * from pw_threads where ifcheck=1 order by postdate desc limit 5";
$query = $this->db->query($sql);
$result5 = $query->result_array();
$sql = "select * from pw_threads where ifcheck=1 order by lastpost desc limit 20";
$query = $this->db->query($sql);
$result6 = $query->result_array();
$now = date("D, d M Y H:i:s T");
$output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>
<rss version=\"2.0\">
<channel>
<title>RSS</title>
<link>http://localhost/rss/index.php/rss</link>
<description>A Test RSS</description>
<language>zh-cn</language>
<pubDate>$now</pubDate>
<lastBuildDate>$now</lastBuildDate>
<docs>http://www.rss.com</docs>
<managingEditor>info@rss.com</managingEditor>
<webMaster>info@rss.com</webMaster>
";
for ($i=0;$i<count($result);$i++)
{
$output .= "<item><title>[海归]".$result[$i]['name']."</title>
<link>".site_url ('haigui/detail/'.$result[$i]['id'])."</link>
<description>".strip_tags($result[$i]['title'])."</description>
</item>";
}
for ($i=0;$i<count($result1);$i++)
{
$output .= "<item><title>[随拍]".$result1[$i]['name']."</title>
<link>".site_url ('suipai/viewphoto/'.$result1[$i]['id'])."</link>
<description>".strip_tags($result1[$i]['title'])."</description>
</item>";
}
for ($i=0;$i<count($result2);$i++)
{
$output .= "<item><title>[活动]".$result2[$i]['name']."</title>
<link>".site_url ('event/getdetail/'.$result2[$i]['id'])."</link>
<description></description>
</item>";
}
for ($i=0;$i<count($result3);$i++)
{
$output .= "<item><title>[商务]".$result3[$i]['iname']."</title>
<link>".site_url ('investor/getdetail/'.$result3[$i]['id'])."</link>
<description></description>
</item>";
}
for ($i=0;$i<count($result4);$i++)
{
$output .= "<item><title>[招聘]".$result4[$i]['jname']."</title>
<link>".site_url ('job/getdetail/'.$result4[$i]['id'])."</link>
<description></description>
</item>";
}
for ($i=0;$i<count($result5);$i++)
{
$output .= "<item><title>[故事]".$result5[$i]['subject']."</title>
<link>".base_url ().'bbs/read.php?tid='.$result5[$i]['tid']."</link>
<description></description>
</item>";
}
for ($i=0;$i<count($result6);$i++)
{
$output .= "<item><title>[最新回复]".$result6[$i]['subject']."</title>
<link>".base_url ().'bbs/read.php?tid='.$result6[$i]['tid']."</link>
<description></description>
</item>";
}
$output .= "</channel>
</rss>";
header("Content-type: application/xml");
echo $output;
?>
复制代码
可以参考下我做的这个....主要就是xml格式而已,弄好了很easy
|
|