gc40 Posted October 16, 2007 Share Posted October 16, 2007 I am building an RSS feed for my site that is going to use the database entries to populate the latest 15 entries on the RSS feed. Its been completed and works fine, except two problems. #1. The description field which is a text field with unlimited characters outputs in pull. I would like to limit this to 200 CHAR. Is there a command I can use to limit the field description from outputting the full article to only allow an output of 200 words? #2. Whenever there is an apostrophe s (') it displays it in the RSS feed as a triangle like it does not recognize the character. Does anyone have an idea of how I can get the feed to pull database entries with the ' and not have them displayed as triangles with question marks? Here is the code below: <? header('Content-type: text/xml'); ?> <rss version="2.0"> <channel> <title>MYBLOG</title> <description>Blog Description</description> <link>http://www.mydomain.com/</link> <copyright>http://www.mydomain.com</copyright> <? include "./class/config.php"; $result = mysql_query("SELECT * FROM `blog` ORDER BY `BLOGID` DESC LIMIT 15"); while($r=mysql_fetch_array($result)) { $TITLE=$r["TITLE"]; $BLOG=$r["BLOG"]; $BLOGID=$r["BLOGID"]; echo "<item>"; ?> <title><?=htmlentities(strip_tags($TITLE)); ?></title> <description><?=htmlentities(strip_tags($BLOG,'ENT_QUOTES'));?></description> <link>http://www.domain.com/blog.php?id=/<?=$BLOGID?></link> <? echo "</item>"; } ?> </channel> </rss> Quote Link to comment https://forums.phpfreaks.com/topic/73537-dynamic-rss-feed-using-php/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.