Shadowing Posted December 31, 2011 Share Posted December 31, 2011 I notice that my text gets saved correctly formated in mysql but when I go to display it its not formated anymore. Anyone know what can I do to get it to display correctly? Quote Link to comment Share on other sites More sharing options...
SergeiSS Posted December 31, 2011 Share Posted December 31, 2011 Try to show it: // version 1 echo '<pre>'.$your_text.'</pre>'; // version 2 echo '<textarea>'.$your_text.'</textarea>'; BTW, do you enter your text via a form, inside textarea tag? Quote Link to comment Share on other sites More sharing options...
jcbones Posted December 31, 2011 Share Posted December 31, 2011 I suppose that you are wanting to preserve new lines? As HTML formatting should remain intact (unless you are using htmlentities). If so, you need to look at nl2br. Quote Link to comment Share on other sites More sharing options...
scootstah Posted December 31, 2011 Share Posted December 31, 2011 Vague questions get vague answers. What is the formatting supposed to be and what is it showing? Quote Link to comment Share on other sites More sharing options...
Shadowing Posted January 1, 2012 Author Share Posted January 1, 2012 thanks for the responces guys im using <textarea>Message</textarea> on the way in. Im not using any tags when displaying it. <?php echo "<td colspan='160'><div class='ex'>$message</div></td></tr>"; ?> i tried <pre> and that made it go out side my box outline. It looks like this below where it shows no line breaks and i want there to be line breaks The total width of an element should be calculated like this: Total element width = width + left padding + right padding + left border + right border + left margin + right margin The total height of an element should be calculated like this: Total element height = height + top padding + bottom padding + top border + bottom border + top margin + bottom margin but I want it to look like Quote Link to comment Share on other sites More sharing options...
scootstah Posted January 1, 2012 Share Posted January 1, 2012 <?php echo "<td colspan='160'><div class='ex'>" . nl2br($message) . "</div></td></tr>"; ?> Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted January 1, 2012 Share Posted January 1, 2012 OP, colspan='160'? Are you sure you know what the colspan attribute does? Quote Link to comment Share on other sites More sharing options...
Shadowing Posted January 2, 2012 Author Share Posted January 2, 2012 yah im coming back in a month with CSS just getting functions working. I know if i get rid of the col span it really messes something up. I tried your suggustion out scoot. using " " gave me a snytax error so I used ' ' it just added 'n12br' to the message. I was doing some reading and for what I read it should be grabing it out of the data base exactly how it is in the data base. the colspam doesnt seem to be effecting it I took a picture of it below Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted January 2, 2012 Share Posted January 2, 2012 It's nl2br, as in en ell (two) bee are, not en (twelve) bee are. Quote Link to comment Share on other sites More sharing options...
Shadowing Posted January 2, 2012 Author Share Posted January 2, 2012 nice that might just work now. now my text editor is lighting up nl2br as red my problem now is getting past the snytax error with the quotes. I tried replacing the " with single qoutes on each side of the nl2br$message but that doesnt work. and i cant get rid of the double quotes on the out side cause of the variable existing. i never came accross a snytax issue like this one before. I even tried breaking the echo up and only echoing in echo "<td>" . nl2br$message . "</td>"; orginal code below echo "<td colspan='160'><div class='ex'>" . nl2br$message . "</div></td></tr>"; Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted January 2, 2012 Share Posted January 2, 2012 Perhaps you should read the examples in the manual: nl2br Quote Link to comment Share on other sites More sharing options...
Shadowing Posted January 2, 2012 Author Share Posted January 2, 2012 thanks Pikachu I got it working echo nl2br("<td colspan='160'><div class='ex'>$message</div></td></tr>"); 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.