Rss feed不会返回来自数据库的所有行

时间:2018-10-11 12:40:00

标签: php wordpress

当我从数据库中检索数据时,我一直在按单词生成自定义rss feed,它显示计数正确,但是当我返回rss feed时,它不能正确返回数据

这是我的代码

 $connection = @mysql_connect(DB_HOST, DB_USER, DB_PASSWORD)
        or die('Could not connect to database');
    mysql_select_db(DB_NAME)
        or die ('Could not select database');

    $query = "SELECT * FROM bm_posts WHERE post_type LIKE 'news' AND post_status = 'publish' ORDER BY ID DESC ";

    $result = mysql_query($query) or die ("Could not execute query");

    while($row = mysql_fetch_array($result)) {
    $title=$row['post_title']; 
    $link=$row['guid']; 
    $description=$row['post_content'];   
   $descriptLimit = substr($description, 0, 50);
   $text=htmlspecialchars($descriptLimit, ENT_COMPAT,'ISO-8859-1', true);

  $date=$row['post_date'];

        echo "<item>";
        echo "<title>$title</title>"; 
        echo "<link>$link</link>"; 
        echo "<description>$text</description>"; 
        echo "<pubDate>$date</pubDate>";
        echo "</item>"; 

    } 
 echo "</channel></rss>"; 

0 个答案:

没有答案