Jump to content

Textarea wordwrap


Hulio

Recommended Posts

Hi,

I'm using a guestbook in my website which uses a MySql database. The problem is that when somebody writes a very long word, a link for example in a textarea field, it breaks the whole structure and layout of my website!! So is there a way to limit those long words with some kind of wordwrapping method?! Here is the code I'm using for printing the content from the database:

[code]
for($ii = 0; $ii < mysql_numrows($result); $ii++) {
echo "<h1>";
echo mysql_result($result,$ii,"Topic");
echo "</h1>";
echo "<p>";
echo nl2br(mysql_result($result,$ii,"Txt"));
echo "</p>";
echo "<p>";
echo mysql_result($result,$ii,"Sender");
echo " - ";
echo mysql_result($result,$ii,"Time");
echo "</p>";
}
[/code]
Link to comment
https://forums.phpfreaks.com/topic/28867-textarea-wordwrap/
Share on other sites

[code]for($ii = 0; $ii < mysql_numrows($result); $ii++) {
echo "<h1>";
echo mysql_result($result,$ii,"Topic");
echo "</h1>";
echo "<p>";
echo wordwrap(nl2br(mysql_result($result,$ii,"Txt")),"20","<br>"); #i'm assuming this is your text
echo "</p>";
echo "<p>";
echo mysql_result($result,$ii,"Sender");
echo " - ";
echo mysql_result($result,$ii,"Time");
echo "</p>";
}[/code]
Link to comment
https://forums.phpfreaks.com/topic/28867-textarea-wordwrap/#findComment-132163
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.