Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 7 of 7

Thread: Line Break

  1. #1
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    I have no clue how to do this, but here it goes...

    I have a textarea. How do I put in line breaks using PHP where the user has put in new lines in the textarea?

    I am having the problem that I submit the text in the textarea to a database (as text), then retrieve and echo it, but the line breaks are taken out and I just get one big clump of text.

    Hope I have made sense,

    Thanks
    JR

  2.  

  3. #2
    Member Black Vivi's Avatar
    Join Date
    Apr 2003
    Location
    UK
    Posts
    75
    Member #
    1072
    PHP Code:
    echo(nl2br($TEXTVAR)); 
    Download Firebird now!

  4. #3
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    Is this before it goes into the database or after it comes out?
    JR

  5. #4
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    Tried both, neither worked
    JR

  6. #5
    Senior Member Brak's Avatar
    Join Date
    Apr 2003
    Location
    San Francisco, CA
    Posts
    3,413
    Member #
    1217
    Liked
    2 times
    nl2br shoud work, it converts all \n's to <br> . before or after is your decision.
    Kyle Neath: Rockstar extraordinare
    The blog | The poetry site | The Spore site

  7. #6
    Member DiZASTiX's Avatar
    Join Date
    Jun 2003
    Posts
    40
    Member #
    1840
    Say you have the textarea and the area is named "text"

    Code:
    <form>
    <input name="text" type="text">
    </form>
    Then when you submit the form it sends it to the database, but before you send it do this:

    PHP Code:
    $text nl2br($text); 
    If you show me what you are doing I could explain better...

  8. #7
    Senior Member
    Join Date
    Mar 2003
    Location
    Hegelsom, The Netherlands
    Posts
    104
    Member #
    834
    Correct DiZASTiX.
    Also some info about it here:
    http://www.php.net/nl2br
    Guess who's back! It's me! Tim 2K


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 08:05 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com