Absolute width in table

admin

Administrator
Staff member
I'm programming a guestbook in php and I want a table with exact width. I want the height to extend if the text gets longer.<br />
I've tried textareas but then I don't know what to put as rows="?". <br />
I've also tried putting in a div but if the table extends the div width the div extends to. <br />
<br />
The only solution i've found is to put <wbr> between each character in the output text in the td. And that isn't a good solution.<!--content-->Hi,<br />
<br />
Am I missing something? Why does this not work?<br />
<br />
<table width="400"><br />
<tr><br />
<td><br />
<br />
</td><br />
</tr><br />
</table><br />
<br />
???<!--content-->If I fill the td with about a thousand W's, then it doesn't work...<!--content-->I'm assuming you mean:<br />
<br />
<table width="400"> <br />
<tr> <br />
<td> <br />
thousands of W's go here w w w w w w w w w w w w<br />
</td> <br />
</tr> <br />
</table><br />
<br />
I'm sorry, it seems to be working for me. Am I understanding the problem that at some point the table expands? Or, the the W's like this: wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww?<!--content-->a thousand W's like WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW WWWWW<!--content-->they seem to have solved it on this site by adding <br> if a line is too long. But I want better solution.<!--content-->How about not using a table and just use a div? <br />
<br />
<br />
<div width:400px><br />
<div width:100%; clear:both;><br />
wwwww<br />
</div><br />
<br />
<br /><br />
<br />
<div width:100%; clear:both;><br />
wwwww<br />
</div><br />
</div><!--content-->My bad...<br />
<br />
<div style="width=400"> <br />
<br />
I forgot to put in the style=""<br />
<br />
hilsen<!--content-->any way is fine, as long as they work. But that way didn't work.<br />
And I did change from <div style="width=400"> to <div style="width:400"><!--content-->You need a unit identifier after that 400 -- such as px, em, %, ex, ect.<br />
If there aren't any spaces in the text, then it won't wrap. There's probably a way to get it to wrap, but if there aren't spaces, it won't wrap. I'm sure there will be spaces in the GB entries.<!--content-->I'm also quite sure there will be spaces in GB entries. But the whole thing is a school-project and some of my classmates will do anything to f**k it up.<!--content-->Originally posted by Robin_R <br />
I'm also quite sure there will be spaces in GB entries. But the whole thing is a school-project and some of my classmates will do anything to f**k it up. <br />
Hehehe, that's gotta suck. Maybe you could add something in that would delete/not allow the entry of there aren't any spaces in it? I dunno, I don't know much about PHP yet.<!--content-->cant you use the php function nl2br()? to make it auto<br><!--content-->nl2br() just makes <br> where there is a /n in the input. I want a new line whenever the line reaches a certain width, so that it doesn't extend my table. I thought wordwrap() with "<wbr>" every tenth letter would do it, but then some spaces went from " " to "<wbr>".<br />
Guess I'll have to write a php-function by myself.<!--content-->You can protect yourself on the server side as you refer to or you can ditch the table and use a div with overflow:hidden since, as you say, the situation is one of invalid input in the first place. Why would you want to show some idiot his bazillion W word and reinforce that behaviour anyway? ;)<!--content-->Robin, I found this javascript at <!-- w --><a class="postlink" href="http://www.javascriptsource.com">www.javascriptsource.com</a><!-- w --> which may help you. <!-- m --><a class="postlink" href="http://javascript.internet.com/forms/line-wrapper.html">http://javascript.internet.com/forms/line-wrapper.html</a><!-- m -->. It seems it will autowrap the text in the text box and I'm wondering if you could manipulate it to work for you? Maybe you could even repost your question in the javascript section.<!--content-->Finally found a solution. Well, I didn't, but my webdesign-teacher did. <br />
<br />
style="word-wrap:break-word; width:200px" <br />
<br />
solved it all.<br />
<br />
BTW: Thank you all for the help<!--content-->Originally posted by Robin_R <br />
Finally found a solution. Well, I didn't, but my webdesign-teacher did. <br />
<br />
style="word-wrap:break-word; width:200px" <br />
<br />
solved it all.<br />
<br />
BTW: Thank you all for the help Only in IE I suspect.<!--content-->'overflow:auto' is one choice.<br />
<br />
This locks the div at your specified dimensions and adds scroll bars ONLY WHEN NEEDED. Scroll bars are only visible if needed. Absent if not needed.<br />
<br />
'word-wrap:break-word' is another choice. I use 'overflow:auto' and fixed width/height to maintain a uniform appearance.<!--content-->
 
Back
Top