Jump to content

overflowing table


OLM3CA

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
Link to comment
https://forums.phpfreaks.com/topic/18060-overflowing-table/
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]
Link to comment
https://forums.phpfreaks.com/topic/18060-overflowing-table/#findComment-77403
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.
Link to comment
https://forums.phpfreaks.com/topic/18060-overflowing-table/#findComment-77406
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.
Link to comment
https://forums.phpfreaks.com/topic/18060-overflowing-table/#findComment-77414
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
Link to comment
https://forums.phpfreaks.com/topic/18060-overflowing-table/#findComment-77419
Share on other sites

Archived

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

×
×
  • Create New...

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.