How do I keep the table from stretching out?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Jsn7821
Forum Newbie
Posts: 5
Joined: Fri Dec 05, 2003 6:08 pm

How do I keep the table from stretching out?

Post 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
Jsn7821
Forum Newbie
Posts: 5
Joined: Fri Dec 05, 2003 6:08 pm

Post 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.
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

You'd probably have to parse the inputted text for long words. Then break them up or something.
Jsn7821
Forum Newbie
Posts: 5
Joined: Fri Dec 05, 2003 6:08 pm

Post 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.
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post 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.
User avatar
Sevengraff
Forum Contributor
Posts: 232
Joined: Thu Apr 25, 2002 9:34 pm
Location: California USA
Contact:

Post by Sevengraff »

Look at [php_man]wordwrap[/php_man]
Post Reply