开发者

have problem about displaying html

开发者 https://www.devze.com 2023-04-04 03:25 出处:网络
I have a problem about displaying HTML using data from MySQL. I using tinyMCE, and content will save as HTML format.

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 characters

Assume 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

0

精彩评论

暂无评论...
验证码 换一张
取 消