Jump to content


Photo

overflowing table


  • Please log in to reply
13 replies to this topic

#1 OLM3CA

OLM3CA
  • Members
  • PipPipPip
  • Advanced Member
  • 52 posts
  • LocationCyprus

Posted 19 August 2006 - 11:15 PM

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
AMD rather than Intel , PHP rahter than ASP

#2 Yesideez

Yesideez
  • Members
  • PipPipPip
  • Advanced Member
  • 2,334 posts
  • LocationDevon, UK

Posted 19 August 2006 - 11:20 PM

Can you post some code that makes the tables?
Not a pro just an enthusiast :)

if (empty($coffee)) {$coffee=new coffee();}

Please surround any code using the CODE tags - I rarely look at anything without them

#3 OLM3CA

OLM3CA
  • Members
  • PipPipPip
  • Advanced Member
  • 52 posts
  • LocationCyprus

Posted 19 August 2006 - 11:37 PM

<table border='1' bordercolor='#E8E8E8' width='700' cellpadding='2' cellspacing='0' class='tablo'>
        <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>
      </table>
AMD rather than Intel , PHP rahter than ASP

#4 Yesideez

Yesideez
  • Members
  • PipPipPip
  • Advanced Member
  • 2,334 posts
  • LocationDevon, UK

Posted 19 August 2006 - 11:43 PM

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.
Not a pro just an enthusiast :)

if (empty($coffee)) {$coffee=new coffee();}

Please surround any code using the CODE tags - I rarely look at anything without them

#5 OLM3CA

OLM3CA
  • Members
  • PipPipPip
  • Advanced Member
  • 52 posts
  • LocationCyprus

Posted 19 August 2006 - 11:49 PM

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
AMD rather than Intel , PHP rahter than ASP

#6 Yesideez

Yesideez
  • Members
  • PipPipPip
  • Advanced Member
  • 2,334 posts
  • LocationDevon, UK

Posted 19 August 2006 - 11:51 PM

Sorry but I don't understand what you mean by "text that the user posts" - can you show an example of this text?
Not a pro just an enthusiast :)

if (empty($coffee)) {$coffee=new coffee();}

Please surround any code using the CODE tags - I rarely look at anything without them

#7 OLM3CA

OLM3CA
  • Members
  • PipPipPip
  • Advanced Member
  • 52 posts
  • LocationCyprus

Posted 19 August 2006 - 11:56 PM

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
AMD rather than Intel , PHP rahter than ASP

#8 Yesideez

Yesideez
  • Members
  • PipPipPip
  • Advanced Member
  • 2,334 posts
  • LocationDevon, UK

Posted 20 August 2006 - 12:04 AM

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.
Not a pro just an enthusiast :)

if (empty($coffee)) {$coffee=new coffee();}

Please surround any code using the CODE tags - I rarely look at anything without them

#9 OLM3CA

OLM3CA
  • Members
  • PipPipPip
  • Advanced Member
  • 52 posts
  • LocationCyprus

Posted 20 August 2006 - 12:09 AM

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...
AMD rather than Intel , PHP rahter than ASP

#10 Yesideez

Yesideez
  • Members
  • PipPipPip
  • Advanced Member
  • 2,334 posts
  • LocationDevon, UK

Posted 20 August 2006 - 12:14 AM

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.htmlcodet...es/_IFRAME.html
Not a pro just an enthusiast :)

if (empty($coffee)) {$coffee=new coffee();}

Please surround any code using the CODE tags - I rarely look at anything without them

#11 OLM3CA

OLM3CA
  • Members
  • PipPipPip
  • Advanced Member
  • 52 posts
  • LocationCyprus

Posted 20 August 2006 - 12:20 AM

ok thanks Yesideez for your help I will check the text first by admin panel than make it viewable ;)
THANKS AGAIN.
AMD rather than Intel , PHP rahter than ASP

#12 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 20 August 2006 - 12:25 AM

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.

#13 OLM3CA

OLM3CA
  • Members
  • PipPipPip
  • Advanced Member
  • 52 posts
  • LocationCyprus

Posted 20 August 2006 - 12:27 AM

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
AMD rather than Intel , PHP rahter than ASP

#14 Yesideez

Yesideez
  • Members
  • PipPipPip
  • Advanced Member
  • 2,334 posts
  • LocationDevon, UK

Posted 20 August 2006 - 12:49 AM

hitman that function was unknown to me until now - thanks from me as well :)
Not a pro just an enthusiast :)

if (empty($coffee)) {$coffee=new coffee();}

Please surround any code using the CODE tags - I rarely look at anything without them




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users