By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,968 Members | 1,410 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,968 IT Pros & Developers. It's quick & easy.

How to format text retrieved from an MSQL Database

P: 2
I have an application that writes text to a MySQL data base from an HTML form. The text in the MySQL table retains the formatting in the form (line breaks etc.) However when I retrieve the text and display it in an HTML layer all the formatting is gone.

Is there any way PHP can retrieve the formatting from the database?There's no way I can write code to do the formatting because I don't know how it was originally entered.
Aug 6 '07 #1
Share this Question
Share on Google+
3 Replies


100+
P: 228
jx2
i think u need this

u might try wordwrap(); too

hope tht help
jx2
Aug 6 '07 #2

P: 2
Hi,

I found a solution;

<?php echo nl2br(str_replace(" ","&nbsp",stripslashes($row["textsum"]))); ?>

the nl2br function puts line breaks in and the str_replace puts the spaces back in.
Aug 7 '07 #3

ak1dnar
Expert 100+
P: 1,584
Hi,

I found a solution;

<?php echo nl2br(str_replace(" ","&nbsp",stripslashes($row["textsum"]))); ?>

the nl2br function puts line breaks in and the str_replace puts the spaces back in.
Glad you got it working. post back any time if you have any issues!
Aug 7 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.