|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to use <pre> </pre> preformatted text
I want to output spaces and returns in an output view from a textbox in a form ... can I use the html <pre> for preformatted text inside a text box with php and a mysql database? Currently, all info added to text box is all smashed together when I display info., except for spaces between words. Return lines are ignored... any suggestions? A return line in html is <br> or <p>, I don't want users to have to enter code...
Hope I explained this okay. I have form users enter for Form Mail, but the text box info. is not very pretty when displayed. Any suggestions? Thanks.
__________________
bow wow! |
|
#2
|
|||
|
|||
|
This code works... you might want to wordwrap() the text though, because if you don't, the visitors can ruin your site layout by entering a very long word.. hope this helps
PHP Code:
You can try out the code above at http://lindset.servehttp.com/pre_test.php
__________________
Best Regards, Håvard Lindset Last edited by Lindset : November 1st, 2002 at 02:39 PM. |
|
#3
|
|||
|
|||
|
I got it to work
I tried your advice but I was not posting back to myself, or maybe I didn't understand your message. Here is what I did to make it work..for me.
echo "<table width='500' border='1' align='left'>"; echo "<tr>"; echo "<td width='500' border='0' align='left'>"; echo "<h4>"; echo "<pre>"; echo $row["message"]; echo "</pre>"; echo "</h4>";[PHP] Anyway, it will show the text as it is entered in the form, in "viewformpage" that I use for all sorts of functions. I have a school newsletter that teachers write, using a form, now they can just enter spaces and returns : ). I have a rather long newsletter that spans several pages. One of those long winded teachers. But if gets ugly when his titles don't follow the coorisponding text. Any idea how to set the page to calculate the length of lines and put the rest on another (while it also takes with it the title to the textbox... maybe a "Title.cont." and the rest of the textbox) page. They look fine online but when printing...yuck. I like the way this site has a print feature... anyone have the code for that? Thanks for all everyones help. |
|
#4
|
|||
|
|||
|
You can also try using regular expressions:
PHP Code:
It will replace any linefeeds (when enter is pressed) with a <br> tag... And replaces the double linefeeds with a paragraph <p>. Hope it helps.
__________________
____________________________________________ Developer Shed Weekly Writer | DevArticles Forum Moderator Build Your Own KlipFolio Klip With PHP FrankManno.com - Under Construction Design Interactive Group - Under Construction |
|
#5
|
|||
|
|||
|
Quote:
nl2br() ![]() |
|
#6
|
|||
|
|||
![]() You got me! hehehe... |
|
#7
|
|||
|
|||
|
great help!
I tried my method my with the <pre> </pre> , but when I dropped in text from MsWord, it went across the page, since Word didn't require a return to go to next line, there were none. I tried inserting a wordwrap() to solve it, but the <pre></pre> took presidence over the wordwrap().
I'll try your suggestion FrankieS. And get back to ya with the answer. The wordwrap() works great if left alone, although it smashes it all together. Anyone know a tutorial on making print friendly pages, like the tutorials on devscripts site? I think the world of these tutorials, I print em out and have a personal ref. of em all. Great help! |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > How to use <pre> </pre> preformatted text |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|