Pars
Pars

Reputation: 5262

have problem about displaying html

I have a problem about displaying HTML using data from MySQL.

I using tinyMCE, and content will save as HTML format.

When 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>

Upvotes: 0

Views: 99

Answers (2)

Tarek
Tarek

Reputation: 3798

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/

Upvotes: 1

Marco Johannesen
Marco Johannesen

Reputation: 13134

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

Upvotes: 0

Related Questions