Jump to content

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/73537-dynamic-rss-feed-using-php/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.