johnwayne77 Posted February 16, 2009 Share Posted February 16, 2009 this is my problem: i have a table row which should be maximum 100px wide. this row is populated by text extracted from a database. sometimes words from this text are too long and exceeds the 100px width which screws up my design. any idea how i can brake up that word after 100px to a next line? thanks Quote Link to comment https://forums.phpfreaks.com/topic/145469-solved-brake-up-word-issue/ Share on other sites More sharing options...
djjamiegee Posted February 19, 2009 Share Posted February 19, 2009 post your code and ill take a look jamie Quote Link to comment https://forums.phpfreaks.com/topic/145469-solved-brake-up-word-issue/#findComment-765766 Share on other sites More sharing options...
johnwayne77 Posted February 19, 2009 Author Share Posted February 19, 2009 well, it's kind of general let's say we havethis: <table> <tr> <td width=10px> 111111111111111111111111111111111111111111111111111 </td> </tr> </table> because the text 111111... is long charactered, it won't stop at 10px wide but it will wide as far as the text goes.. that screws up my design i dont have any solution yet Quote Link to comment https://forums.phpfreaks.com/topic/145469-solved-brake-up-word-issue/#findComment-766046 Share on other sites More sharing options...
djjamiegee Posted February 19, 2009 Share Posted February 19, 2009 hi i am still new to this but i just tested your code and from what i have picked up is that if you have multiple words then when it reaches the end of the column it will break that new word to a new link but if the word is really long then it cant split the word up so it has no option to extend the table. i have tried fixing it with other solutions and css but i have had no luck. jamie Quote Link to comment https://forums.phpfreaks.com/topic/145469-solved-brake-up-word-issue/#findComment-766063 Share on other sites More sharing options...
gethinw Posted February 19, 2009 Share Posted February 19, 2009 I'm not 100% sure on exactly how different browsers handle this, but in firefox at least table cells seem to expand if text can't be split, whereas div's stay the specified size. That said, it still won't split the word across lines, and instead will either show it outside the div, or hide the extra bit, or show a scroll bar on the div, depending on what your 'overflow' attribute is set to. That's probably not much help i'm afraid - I think your best bet is going to be to manually split the words. Quote Link to comment https://forums.phpfreaks.com/topic/145469-solved-brake-up-word-issue/#findComment-766089 Share on other sites More sharing options...
johnwayne77 Posted February 19, 2009 Author Share Posted February 19, 2009 yeah, if it were so easy.. my content is extracted from mysql...so no way of manual cutting... when the word is wider than 10px, it auto expands the table cell, screwing up my design... there must be something somewhere around to fix this issue, i'm sure.. i'm still searching oh, tell me more about the div solution.. Quote Link to comment https://forums.phpfreaks.com/topic/145469-solved-brake-up-word-issue/#findComment-766505 Share on other sites More sharing options...
haku Posted February 20, 2009 Share Posted February 20, 2009 Set the width of the cell in CSS. That should keep it at that width. Quote Link to comment https://forums.phpfreaks.com/topic/145469-solved-brake-up-word-issue/#findComment-766874 Share on other sites More sharing options...
gethinw Posted February 20, 2009 Share Posted February 20, 2009 Use php (or whatever you're using to get the data from the DB) to automatically insert a break if a word is over a certain number of characters long? Using divs - it'll mean you have to redesign your site using <div> tags instead of tables. It's hard to say much more without knowing what you're trying to do! re haku: have you checked that? all the examples I've tried seem to expand the table cell to fit the content, no matter how you define the width. Quote Link to comment https://forums.phpfreaks.com/topic/145469-solved-brake-up-word-issue/#findComment-767038 Share on other sites More sharing options...
johnwayne77 Posted February 20, 2009 Author Share Posted February 20, 2009 @gethinw: yeah, that is what i was looking for.. but no luck yet.. neither <wbr> nor wordwrap php function seems not to work or i don't know how to use it any advices? Quote Link to comment https://forums.phpfreaks.com/topic/145469-solved-brake-up-word-issue/#findComment-767088 Share on other sites More sharing options...
jcombs_31 Posted February 20, 2009 Share Posted February 20, 2009 From what I can tell I think you'll have to dynamically break up the long string in order for it to wrap properly. IE has a word-wrap feature but it is only for IE. Quote Link to comment https://forums.phpfreaks.com/topic/145469-solved-brake-up-word-issue/#findComment-767115 Share on other sites More sharing options...
johnwayne77 Posted February 20, 2009 Author Share Posted February 20, 2009 yeah, something dinamically indeed chunk_split maybe? Quote Link to comment https://forums.phpfreaks.com/topic/145469-solved-brake-up-word-issue/#findComment-767118 Share on other sites More sharing options...
Mchl Posted February 20, 2009 Share Posted February 20, 2009 Did you try wordwrap with fourth argument ($cut) set to TRUE? Quote Link to comment https://forums.phpfreaks.com/topic/145469-solved-brake-up-word-issue/#findComment-767126 Share on other sites More sharing options...
johnwayne77 Posted February 20, 2009 Author Share Posted February 20, 2009 ok, this works: $newtext = wordwrap($titlurez, 8, "\n", true); is better than chunk_split Quote Link to comment https://forums.phpfreaks.com/topic/145469-solved-brake-up-word-issue/#findComment-767141 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.