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.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
  1. #1
    Member DiZASTiX's Avatar
    Join Date
    Jun 2003
    Posts
    40
    Member #
    1840
    I made a form to write articles for my site, I just input the info and it generates the page. Just have a minor problem with the layout. Say I enter this:

    This is some text right here...isnt it cool.

    Here is some more text, nice.
    It shows as this:

    This is some text right here...isnt it cool. Here is some more text, nice.
    In order to get it to be on seperate lines, I have to use <br> How do I change this? I know it is possible, because of me writing this. The form I use to post this thread, when I press enter, it shows the enter when I post it...

  2.  

  3. #2
    Senior Member skrlin's Avatar
    Join Date
    Apr 2003
    Location
    Illinois
    Posts
    562
    Member #
    1063
    PHP Code:
    // Say $text is the variable that the article text is stored in
    $text nl2br($text); 
    - Brian

  4. #3
    Senior Member skrlin's Avatar
    Join Date
    Apr 2003
    Location
    Illinois
    Posts
    562
    Member #
    1063
    Try http://us3.php.net/nl2br for more info on that function and others like it.
    - Brian

  5. #4
    Member DiZASTiX's Avatar
    Join Date
    Jun 2003
    Posts
    40
    Member #
    1840
    Thankyou, It works like a charm!

    *smacks himself for forgetting to check php.net*


  6. #5
    Senior Member skrlin's Avatar
    Join Date
    Apr 2003
    Location
    Illinois
    Posts
    562
    Member #
    1063
    Well, you came to the next best place
    - Brian

  7. #6
    Junior Member cinq's Avatar
    Join Date
    Jun 2003
    Posts
    18
    Member #
    1971
    Originally posted by skrlin
    PHP Code:
    // Say $text is the variable that the article text is stored in
    $text nl2br($text); 
    Is this function only meant for output ?

    Should i have an input form (for eg. an input textbox for people to submit their poems and save it as a variable into a database), will the input into the database permit for line breaks where the user enters into the text box by using the nl2br function ?

  8. #7
    Senior Member skrlin's Avatar
    Join Date
    Apr 2003
    Location
    Illinois
    Posts
    562
    Member #
    1063
    If I understand you correctly, and you mean that the user would type out a poem into a <textarea name="poem"></textarea> (just an example) field and on submittal any line breaks would be translated into "<BR />" and stored in a database to be displayed as HTML at a later time, then yes as far as I know that should work.
    - Brian

  9. #8
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    you should only use text formatting functions on output. reason being, if your user is going to modify the text in the database, you don't want to be showing them the html formatting.

  10. #9
    Senior Member skrlin's Avatar
    Join Date
    Apr 2003
    Location
    Illinois
    Posts
    562
    Member #
    1063
    Good point.
    - Brian

  11. #10
    WDF Staff Wired's Avatar
    Join Date
    Apr 2003
    Posts
    7,657
    Member #
    1234
    Liked
    138 times
    I believe there MAY be a PHP command that can strip all HTML code from something, so if you set it up right, it could be editable after using this command.
    The Rules
    Was another WDF member's post helpful? Click the like button below the post.

    Admin at houseofhelp.com


Page 1 of 2 1 2 LastLast

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 02:37 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com