OLM3CA Posted August 19, 2006 Share Posted August 19, 2006 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 More sharing options...
Yesideez Posted August 19, 2006 Share Posted August 19, 2006 Can you post some code that makes the tables? Link to comment https://forums.phpfreaks.com/topic/18060-overflowing-table/#findComment-77398 Share on other sites More sharing options...
OLM3CA Posted August 19, 2006 Author Share Posted August 19, 2006 [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ıt 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önderen</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şlık</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 More sharing options...
Yesideez Posted August 19, 2006 Share Posted August 19, 2006 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 More sharing options...
OLM3CA Posted August 19, 2006 Author Share Posted August 19, 2006 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 Link to comment https://forums.phpfreaks.com/topic/18060-overflowing-table/#findComment-77410 Share on other sites More sharing options...
Yesideez Posted August 19, 2006 Share Posted August 19, 2006 Sorry but I don't understand what you mean by "text that the user posts" - can you show an example of this text? Link to comment https://forums.phpfreaks.com/topic/18060-overflowing-table/#findComment-77411 Share on other sites More sharing options...
OLM3CA Posted August 19, 2006 Author Share Posted August 19, 2006 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 Link to comment https://forums.phpfreaks.com/topic/18060-overflowing-table/#findComment-77413 Share on other sites More sharing options...
Yesideez Posted August 20, 2006 Share Posted August 20, 2006 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 More sharing options...
OLM3CA Posted August 20, 2006 Author Share Posted August 20, 2006 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... Link to comment https://forums.phpfreaks.com/topic/18060-overflowing-table/#findComment-77417 Share on other sites More sharing options...
Yesideez Posted August 20, 2006 Share Posted August 20, 2006 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 More sharing options...
OLM3CA Posted August 20, 2006 Author Share Posted August 20, 2006 ok thanks Yesideez for your help I will check the text first by admin panel than make it viewable ;) THANKS AGAIN. Link to comment https://forums.phpfreaks.com/topic/18060-overflowing-table/#findComment-77420 Share on other sites More sharing options...
hitman6003 Posted August 20, 2006 Share Posted August 20, 2006 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. Link to comment https://forums.phpfreaks.com/topic/18060-overflowing-table/#findComment-77422 Share on other sites More sharing options...
OLM3CA Posted August 20, 2006 Author Share Posted August 20, 2006 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 Link to comment https://forums.phpfreaks.com/topic/18060-overflowing-table/#findComment-77423 Share on other sites More sharing options...
Yesideez Posted August 20, 2006 Share Posted August 20, 2006 hitman that function was unknown to me until now - thanks from me as well :) Link to comment https://forums.phpfreaks.com/topic/18060-overflowing-table/#findComment-77426 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.