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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.