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] Quote Link to comment Share on other sites More sharing options...
taith Posted November 29, 2006 Share Posted November 29, 2006 $newtext = wordwrap($text, 20, "<br />"); Quote Link to comment 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? Quote Link to comment 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] Quote Link to comment Share on other sites More sharing options...
Hulio Posted November 29, 2006 Author Share Posted November 29, 2006 Cheers! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.