I have a problem about displaying HTML using data from MySQL.
I using tinyMCE, and content will save as HTML format.
W开发者_Python百科hen i want to display it on my browser it displays correctly.
BUT is not working properly when I try to limit 400 charactersAssume this code as MySQL content which i want to display:
<div class="someclass" >
this is content from MySQL
</div>
If limit to 20 characters, there will be no ending </div>
and you can think what will happen without that </div>
If i understand correctly....
you can use the php function to limit the output
// will display only the first 100 chars
$text = substr($desc,0,100);
Edit :
to preserve HTML output
http://alanwhipple.com/2011/05/25/php-truncate-string-preserving-html-tags-words/
What programming language are you sing for the TinyMCE?
From MYSQL you could do
SELECT LEFT(text,400) FROM news...
etc for limiting the characters
精彩评论