Hulio Posted November 29, 2006 Share Posted November 29, 2006 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 More sharing options...
taith Posted November 29, 2006 Share Posted November 29, 2006 $newtext = wordwrap($text, 20, "<br />"); Link to comment https://forums.phpfreaks.com/topic/28867-textarea-wordwrap/#findComment-132148 Share on other sites More sharing options...
Hulio Posted November 29, 2006 Author Share Posted November 29, 2006 Thanks, but where in this code should I add this? Link to comment https://forums.phpfreaks.com/topic/28867-textarea-wordwrap/#findComment-132156 Share on other sites More sharing options...
taith Posted November 29, 2006 Share Posted November 29, 2006 [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 More sharing options...
Hulio Posted November 29, 2006 Author Share Posted November 29, 2006 Cheers! Link to comment https://forums.phpfreaks.com/topic/28867-textarea-wordwrap/#findComment-132288 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.