Results 1 to 4 of 4

Thread: Keep formatting with text area

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2006
    Posts
    11

    Keep formatting with text area

    I have a form in which the user enters data in a text area and the data is saved in my SQL database. The problem is that, for example, if you create a new paragraph in the text area, the formatting is lost when saved to the database and all the sentences are ran together with no blank lines.

    How do I preserve the spacing and formatting used in the text area? Thanks for your help!

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Keep formatting with text area

    Are you sure the formatting is lost upon saving? I very much doubt so. Check the HTML source code that is output.

    I think this happens only upon displaying the HTML. And the reason for it is, of course, that the HTML and CSS specs say that all whitespace is collapsed into a single space character.

    The easiest way to get around this is to user the nl2br() function.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2006
    Posts
    11

    Re: Keep formatting with text area

    Would the wrap="physical" attribute have anything to do with this?

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Keep formatting with text area

    That attribute does not exist in any standard I'm aware of.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width