Reputation: 426
Hey I have on my database a text with 800 chracters when I echo it out it display in just one line getting too big and bad for read,
echo mysql_result(mysql_query("SELECT `message` FROM `pm` WHERE `pm_id` = '1'"));
How do I put
or \n automatic on the end of every line because there is differents datas inserted in the database and do manualy for every one is hard.
edit: I want to meke it like: one \n after 100 characters or something like that.
Upvotes: 0
Views: 146
Reputation: 2681
Use the wordwrap
function: http://www.php.net/manual/en/function.wordwrap.php
echo wordwrap($data, 100, "\n"); // Or use "<br/>" in html
There also is a 4. parameter. If you data does not contain any spaces, wordwrap can not break between words. If you set the 4. parameter to true
, wordwrap will cut no matter if within a word or not.
// cut after 100, no matter if inside a word.
echo wordwrap($data, 100, "\n", true);
Upvotes: 1
Reputation: 690
put it in a div, and set div width. That will solve your problem. Like this:
#CSS
.sample{
width:50px;
}
and here's some sample html
<div class="sample">
#your results from database here
</div>
Upvotes: 0