limit irite output
I just want to put a certain amount of characters on my home page, so it doesn't take up too much room and then link to the page where my full content is written. I'm using iRite for my client to enter their data. Well I ran into a slight snag last night.
I'm using this code to shorten my iRite content:
<?php
$tmp=mysql_query("SELECT * FROM myTable ORDER BY id_myTable DESC");
while($row=mysql_fetch_array($tmp)){
$text = $row_rsmyTable'text_myTable'];
$var = ("$text");
$varlength = strlen($var);
$limit = 200;
if ($varlength > $limit) {
$var = substr($var,0,$limit);
}
}
echo "$var...";
?>
It works great, BUT there's an issue. When it cuts off the text, it apparently leaves some of the tags off that iRite writes to format the content.
Is there a way around this? or am I going to have to add another text field on the back end so they can enter a smaller portion of their content to put on the home page?