Jump to content

Archived

This topic is now archived and is closed to further replies.

OLM3CA

overflowing table

Recommended Posts

hi!
First of all i would like to say that my english is not good enough so sorry about this.
My question is : i am getting datas from Mysql,i put them in a table(not sql table,html).
But i saw that the width of my table become wider (overflow horizantally).
I realised that when i don't use spaces while sending the text,this happens.
I want to add ; i made table widths to a fixed number (700) , İ used to solve this problem by nl2br() function but can't solve.
Now can you help me to solve this question ? i am so confused... Thank You

Share this post


Link to post
Share on other sites
[color=red]<table border='1' bordercolor='#E8E8E8' width='700' cellpadding='2' cellspacing='0' class='tablo'>[/color]
        <tr>
<td colspan='3' bgcolor='#E8E8E8' width='700'></td>
</tr>
<tr bgcolor='#F4F4F4'>
        <td width='70' align='right' bgcolor='#F4F4F4'><strong>Kay&#305t No </strong></td>
        <td width='10' align='right' bgcolor='#F4F4F4'>:</td>
        <td width='620' align='left'>.$row['no'].</td>
        </tr>
        <tr bgcolor='#F4F4F4'>
        <td width='70' align='right' bgcolor='#F4F4F4'><strong>G&oumlnderen</strong></td>
        <td width='10' align='right' bgcolor='#F4F4F4'>:</td>
        <td width='620' align='left'>.$row['isim'].</td>
        </tr>
        <tr bgcolor='#F4F4F4'>
        <td width='70' align='right' bgcolor='#F4F4F4'><strong>Yer</strong></td>
        <td width='10' align='right' bgcolor='#F4F4F4'>:</td>
        <td width='620' align='left'>.$row['sehir'].</td>
        </tr>
        <tr bgcolor='#F4F4F4'>
        <td width='70' align='right' bgcolor='#F4F4F4'><strong>Tarih</strong></td>
        <td width='10' align='right' bgcolor='#F4F4F4'>:</td>
        <td width='620' align='left'>.$row['tarih'].</td>
        </tr>
        <tr bgcolor='#F4F4F4'>
        <td width='70' align='right' bgcolor='#F4F4F4'><strong>Ba&#351l&#305k</strong></td>
        <td width='10' align='right' bgcolor='#F4F4F4'>:</td>
        <td width='620' >.$row['baslik'].</td>
        </tr>
        <tr bgcolor='#F4F4F4'>
        <td width='70' align='right' valign='top' bgcolor='#F4F4F4'><strong>Yorum</strong></td>
        <td width='10' align='right' valign='top' bgcolor='#F4F4F4'>:</td>
        <td width='620'>.$row['msg']</td>
        </tr>
    [color=red]  </table>[/color]

Share this post


Link to post
Share on other sites
If you're not using spaces then the browser will try and squeeze as much in as possible and it will force the table to be wider than what you have set. The only way to stop this from happening is to include spaces - I presume your output is of words?

For example, if your table was 700 wide and you display a picture 800 wide inside a cell the browser wouldn't shrink the image but would instead make the table wider to accomodate the image.

Share this post


Link to post
Share on other sites
Thank you Yesideez but how can I add spaces to the text that user posts. I tried nl2br() function but not solved do you have any idea about adding spaces between the text if you have,I am so glad thanx

Share this post


Link to post
Share on other sites
Sorry but I don't understand what you mean by "text that the user posts" - can you show an example of this text?

Share this post


Link to post
Share on other sites
aham ok works like this :

There is a form for users to post messages name location title and message.when the user post these we send them to database.the text = the message the user sends. I would like to add spaces to this message

Share this post


Link to post
Share on other sites
Surely the users are entering spaces between each word themselves? That should be enough.

When you get the message from the database and display it in a cell in the table as long as you've set a width when you define the table it should stay that width as long as there are no single words longer than the width.

Share this post


Link to post
Share on other sites
okey but the problem is that if a person writes a message with using none space ? what would happen overflows again. I have to solve it becouse i am designing a site with no approval I mean ı dont control.
the messages directly shown in homepage or etc...

Share this post


Link to post
Share on other sites
As far as I'm aware there's no way around this without writing a complex routine to split the message into an array holding each word, find the longest word in the array and if a word is longer than a certain length then don't accept the message.

The big problem would be that nearly all fonts have characters of different widths so this wouldn't be reliable - for example a "W" is a lot wider than an "i"

If your table is 700 wide then I can't really see a word being long enough to ruin it unless someone was being silly when entering their message.

Just thought - you could use an iframe perhaps?
http://www.htmlcodetutorial.com/frames/_IFRAME.html

Share this post


Link to post
Share on other sites
ok thanks Yesideez for your help I will check the text first by admin panel than make it viewable ;)
THANKS AGAIN.

Share this post


Link to post
Share on other sites
Use the wordwrap (http://www.php.net/wordwrap) function with the third parameter, which will force it to wrap all lines, regardless of spaces or anything else, at that number of characters.

Share this post


Link to post
Share on other sites
thank you too hitman how helpfull site is this :) i am glad & lucky to be here i will have lots of questions for you :) goodbye

Share this post


Link to post
Share on other sites
hitman that function was unknown to me until now - thanks from me as well :)

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.