Page 1 of 1

How do I keep the table from stretching out?

Posted: Fri Dec 05, 2003 6:08 pm
by Jsn7821
I wrote a PHP/MySQL script for a tagboard on my website, nothing wrong with it, but when someone types in a long word like "oooooohhhhhhhhhhhhhhh" or a link, it will stretch the table out.

I have thought of a few solutions - in the php code, check to see if they have entered a word longer then x amount of letters, and return an error. Only problem is that wouldn't work for links.

I could put it all in a <textarea> box, but I have it set up so they can change colors and make the text bold and stuff. That wouldn't work in a textarea box.

If there is some kind of wrap for a table that I could use... that would work the best. I tried wrap="physical" but that had no effect on it, didn't think it would.

Right now I can't think of any way to get around this, does anyone here have any ideas?

Thanks

Posted: Fri Dec 05, 2003 6:10 pm
by Jsn7821
The tagboard is located at http://www.static2k.com/php/tagboard/index.php for anyone who needs to see what I am talking about.

Posted: Fri Dec 05, 2003 6:17 pm
by microthick
You'd probably have to parse the inputted text for long words. Then break them up or something.

Posted: Fri Dec 05, 2003 6:22 pm
by Jsn7821
What function would I use? I browsed php.net but couldn't find anything that would work.

Plus, theres no way of knowing how many words would fill up the table. Unless I use a console font, which I am not.

Posted: Fri Dec 05, 2003 6:26 pm
by microthick
explode() the text into an array of separate strings. use a space as a delimiter for explode.

then run through the array of strings and strlen() them all to see if any of them are too long.

Posted: Fri Dec 05, 2003 6:32 pm
by Sevengraff
Look at [php_man]wordwrap[/php_man]