I am hand building a simple CMS for my persona website. I using PHP and MySQL.
The problem I am having is in the PHP code I am using to serve up an RSS feed. I have everything working in it with the exception of the description.
All I am looking to do is display the first 255 characters. So I need a way to clip off the rest of the string. Either in PHP or the MySQL querey.
I am sure there is simply a built in function of this, however I can not find it.
The RSS PHP code if you are interested.
Code: Select all
<?php
header('Content-type: text/xml', true);
print '<?xml version="1.0" encoding="UTF-8"?>';
require('cms/connect.php');
$sql1 = "select * from blog order by dateposted desc limit 10;";
$result1 = @mysql_query($sql1) or die("could not complete your query");
?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Shift-8</title>
<link>http://shift-8.com/</link>
<description>Shift-8.com is the personal website of Steven Smith.</description>
<language>en-us</language>
<?php
while($row1 = mysql_fetch_array($result1)){
$permalink = $row1["dateposted"];
$mtndate = $row1["dateposted"];
$title = $row1["title"];
$post = $row1["post"];
$post = strip_tags($post);
$localdate = $mtndate + 7200;
$readdate = date("Y-m-d", $localdate);
print"\t<item>\n";
print"\t\t<title>$title</title>\n";
print"\t\t<link>http://shift-8.com/?view=archives&post=$permalink</link>\n";
print"\t\t<description>$post</description>\n";
print"\t</item>\n";
}
?>
</channel>
</rss>
<?php mysql_close($connect);
?>