Formatting the contents of a text area form field

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • monomaniac21

    Formatting the contents of a text area form field

    Hi all

    On my site I get users to enter a load of information in a textarea
    box, however when i save this data to my mysql DB and then retrieve it,
    it comes out without all the formatting, like new paragraphs and new
    lines.

    Can anyone tell me how you can capture the data entered into such a
    field with all the formatting the user has entered like new paragraphs
    etc?

  • Charlie King

    #2
    Re: Formatting the contents of a text area form field

    On 15 Jan 2006 04:57:20 -0800, in
    <1137329840.465 536.212360@z14g 2000cwz.googleg roups.com>
    (comp.lang.php) "monomaniac 21" <marcrice20@msn .com> wrote:
    [color=blue]
    > Hi all
    >
    > On my site I get users to enter a load of information in a textarea
    > box, however when i save this data to my mysql DB and then retrieve it,
    > it comes out without all the formatting, like new paragraphs and new
    > lines.
    >
    > Can anyone tell me how you can capture the data entered into such a
    > field with all the formatting the user has entered like new paragraphs
    > etc?[/color]

    You could try nl2br();
    Inserts HTML line breaks before all newlines in a string


    e.g.

    echo nl2br($bigField FromDatabase);
    --
    Charlie

    Comment

    • Chuck Anderson

      #3
      Re: Formatting the contents of a text area form field

      monomaniac21 wrote:
      [color=blue]
      >Hi all
      >
      >On my site I get users to enter a load of information in a textarea
      >box, however when i save this data to my mysql DB and then retrieve it,
      >it comes out without all the formatting, like new paragraphs and new
      >lines.
      >
      >Can anyone tell me how you can capture the data entered into such a
      >field with all the formatting the user has entered like new paragraphs
      >etc?
      >
      >
      >[/color]
      Search for information on the wrap attribute for textarea.

      --
      *************** **************
      Chuck Anderson • Boulder, CO

      Integrity is obvious.
      The lack of it is common.
      *************** **************

      Comment

      • monomaniac21

        #4
        Re: Formatting the contents of a text area form field


        Chuck Anderson wrote:
        [color=blue]
        > Search for information on the wrap attribute for textarea.
        >[/color]
        I have wrap set to "hard" it doesnt make a difference. When I look at
        the phpmyadmin entry there are no tags to indicate a line break. When I
        display the data from the database everything is on one line.

        Comment

        • monomaniac21

          #5
          Re: Formatting the contents of a text area form field

          Charlie i tried yours it worked great cheers

          Comment

          Working...