所以我正在尝试编写一个程序,当添加新的数据库条目时,它会向每个子程序员发送RSS提要。我的代码将为订阅者提供所有当前数据库条目,但在输入新项目时不会发送新的RSS提要。这是我的代码:
<?php
header("Content-Type: application/rss+xml; charset=UTF8_general_ci");
//mysql connection is here
$rssfeed = '<?xml version="1.0" encoding="ISO-8859-1"?><rss version="2.0"><channel>';
//rss feed data
$rssfeed .= '<title>test</title>
//link is here
<description>test</description>
<language>en-us</language>';
//items
$results = mysql_query("SELECT name FROM test");
while($row = mysql_fetch_array($results)){ //looping through items
$rssfeed .= '<item>
<title>' . $row['name'] . '</title>
<description>test</description>
//link to my website here
<pubDate>' . date("F j, Y, g:i a") . '</pubDate>
</item>';
}
$rssfeed .= '</channel></rss>';
echo $rssfeed;