jasonc Posted April 8, 2008 Share Posted April 8, 2008 I am hoping that this can be done using HTML is there an opposite to 'nowrap' (<td NOWRAP><?=$username;?></td>) instead of what i have below that i am currently using, which adds more to the output. meaning the '<br />\n' this is causing problems with the text being copied. say using the double click on text method. ... ... ... <td><? echo wordwrap($text, 11, "<br />\n", true); ?></td> .... .. .. Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted April 8, 2008 Share Posted April 8, 2008 take the \n out... Quote Link to comment Share on other sites More sharing options...
jasonc Posted April 8, 2008 Author Share Posted April 8, 2008 what i mean is so no extra characters are added to what will be outputted. <table> <tr> <td width="11"><? $text = "abcdefghijksdflkjashdflkahfljkhasdfkljhasdfklashflkhasdflkjhadljkhaljksdh"; echo ($text); ?></td> </tr> </table> Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted April 8, 2008 Share Posted April 8, 2008 ah I doubt it matters but have you assigned the output of wordwrap to a var and echoed that??? Just as the examples do in the docs.. <?php $text = "abcdefghijksdflkjashdflkahfljkhasdfkljhasdfklashflkhasdflkjhadljkhaljksdh"; $newtext = wordwrap($text,11,"<br />",true); echo ($newtext); ?> Quote Link to comment Share on other sites More sharing options...
jasonc Posted April 8, 2008 Author Share Posted April 8, 2008 yes ture. but now if you were to double click on this text that would have been echo'd you would only be selecting one line and not all of the text that was echo'd as it now contains <b /> 's this is what i need not to be there but still to have the line break up after so many characters. Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted April 9, 2008 Share Posted April 9, 2008 if this were in a text file then you would need something like this... <?php $text = "abcdefghijksdflkjashdflkahfljkhasdfkljhasdfklashflkhasdflkjhadljkhaljksdh"; $newtext = wordwrap($text,11,PHP_EOL ,true); // if you uare using php < 5 or < 4.3 then it would be \r\n for windows \n for *nix and \r for Mac echo ($newtext); ?> However you want this in a web page so you HAVE to have the <br /> otherwise the whites space is truncated and you will get the text on the same line until it runs out of space... Quote Link to comment Share on other sites More sharing options...
jasonc Posted April 9, 2008 Author Share Posted April 9, 2008 ok what i am wanting is to force the <td> to be a certain width. <table> <tr> <td width="11">abcdefghijksdflkjashdflkahfljkhasdfkljhasdfklashflkhasdflkjhadljkhaljksdh</td> </tr> </table> Quote Link to comment Share on other sites More sharing options...
haku Posted April 9, 2008 Share Posted April 9, 2008 Well now we are getting somewhere. Make your TD look like this: <td class="this_class">jsdfasdfdasjfkdla;fjkd;ajfd;afjdka</td> And add this to the head of your document: <style type="text/css"> .this_class { width: ____px; //set the width you want in pixels here } </style> If you want other cells to be the same width, give them the same class name ("this_class"). When using tables, you only need to set the class name to the cell in the top row - the cells below will all conform to that width (or such has been the case for me up until this point, but I haven't used tables much since learning CSS). Quote Link to comment Share on other sites More sharing options...
jasonc Posted April 9, 2008 Author Share Posted April 9, 2008 i only want to change the first column. so the first column is so many letters wide ________ as you can see this is what i now have and it does not seem to work correctly?! i have tested in FireFox and IE both show the same, but the line is not dropping to the next line when it reaches the max width i set <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> .this_class { width: 150px; //set the width you want in pixels here } </style> </head> <body> <table width="634"> <tr> <td class="this_class">h1 long line</td> <td width="97">h2</td> <td width="100">h3</td> <td width="123">h4</td> <td width="141">h5</td> </tr> <tr> <td>dddddddddddddddddddddddkkkkkkkkkkkkkkkkkkkkkkyyyyyyyyyyyyyyyyyyyyyyffffffffffffffffffffffffffffffffff</td> <td>h2 text</td> <td>h3 text</td> <td>h4 text</td> <td>h5 text</td> </tr> </table> </body> </html> Quote Link to comment Share on other sites More sharing options...
haku Posted April 9, 2008 Share Posted April 9, 2008 Try adding the class name to the next cell in the column (the one containing the text) Quote Link to comment Share on other sites More sharing options...
jasonc Posted April 9, 2008 Author Share Posted April 9, 2008 i have added to both still not working, Quote Link to comment Share on other sites More sharing options...
haku Posted April 9, 2008 Share Posted April 9, 2008 Post a link to your page. If you don't have one, google 'free hosting' and put your page on a free host, then post the link here. Quote Link to comment Share on other sites More sharing options...
jasonc Posted April 9, 2008 Author Share Posted April 9, 2008 this is the full code <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> .this_class { width: 150px; //set the width you want in pixels here } </style> </head> <body> <table width="634"> <tr> <td class="this_class">h1 long line</td> <td width="97">h2</td> <td width="100">h3</td> <td width="123">h4</td> <td width="141">h5</td> </tr> <tr> <td class="this_class">dddddddddddddddddddddddkkkkkkkkkkkkkkkkkkkkkkyyyyyyyyyyyyyyyyyyyyyyffffffffffffffffffffffffffffffffff</td> <td>h2 text</td> <td>h3 text</td> <td>h4 text</td> <td>h5 text</td> </tr> </table> </body> </html> Quote Link to comment 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.