|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have a textarea in a form that a user fills in and then stores the text in mysql as medimum blob and when the users web page is call by any one the data from the db is inserted in to the page content via <?php echo $var ?> .
The problem is how the text is displayed. There is no formating to the text is only a string. How can this text be formated by the user. I am open to suggestions to a better method to the end. What I want to do is like the way you post this message Thanks ------------------ Thanks Dr.E.L. |
|
#2
|
|||
|
|||
|
Let them use HTML within your textarea and store this along with the text. If you echo this the browser will interpret this as normal HTML and so it is formatted.
------------------ Good luck, Bas ------------------ E-mail me at: b.vandermeijden@pecoma.nl |
|
#3
|
||||
|
||||
|
Here's a couple of ideas:
(1) use <pre> tags around the text when it's put back into a web page. The users line breaks are still in there, HTML just ignores them. (2) Since you're using PHP you could use something like newline_to_br() to fix up the text, or even write your own routine to convert multiple newlines into <p>'s. Personally, I'd probably just use the <pre> tags. ![]() Scott |
|
#4
|
|||
|
|||
|
Scott, Thanks for the help I will give it a try. How would I apply newline_to_br() <? echo $var; ?>
Bill |
|
#5
|
|||
|
|||
|
thank you so much for <pre> tags.
they just saved my life. |
|
#6
|
|||
|
|||
|
The PHP function is actually called nl2br()
If your string is called $textentry, you could just do: <? echo nl2br($textentry); ?> This would output the string with a <br> where every carriage return was. |
![]() |
| Viewing: Dev Shed Forums > Web Design > HTML Programming > Textarea formating |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|