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
  1. #1
    Senior Member
    Join Date
    Apr 2005
    Location
    Hatfield, England
    Posts
    855
    Member #
    9790
    My database isn't storing new lines on input boxes. How do i do this? I am currently using a text box with the database text type on my column. Is there a special command you need to add to your input boxes or do you need to use javascript to pick up new lines?

  2.  

  3. #2
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    So you currently have a <textarea> looking something like
    HTML Code:
    <textarea name="ta" id="ta" cols="x" rows="y"></textarea>
    And the user enters something like

    Quote Originally Posted by user
    hello

    goodbye
    To pick up the empty line, you can use nl2br (http://uk2.php.net/manual/en/function.nl2br.php). This became XHTML compliant (<br />) in php 4.0.5

    Usage:
    PHP Code:
    $var $_POST['ta']; // where ta is name of textarea
    $var nl2br($var); 
    Hope this helps.

  4. #3
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Alternatively, you can give divs where inputted text is displayed the CSS property [minicode]white-space: pre;[/minicode]. Or (and I think this is the best solution), look into textile or Markdown or Smartypants.

  5. #4
    Senior Member
    Join Date
    Apr 2005
    Location
    Hatfield, England
    Posts
    855
    Member #
    9790
    nl2br seems to only generate &lt;br /&gt; which produces <br /> written in my page instead of processed by.

    Shadowfiend most of those links are for plug-ins and i'm not using a templating system..

  6. #5
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    nl2br generates <br /> not &lt;br /&gt;

    So my guess is you are using html_entities or str_replace/similar when you have extracted from the DB.

    If you need to keep it like that, you will have to reverse,

    Currently the <br /> is being changed into a html entity.

  7. #6
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    I didn't give you direct links to the implementations, Perad, I gave you the links to the concepts ;-) http://jimandlissa.com/project/textilephp is an implementation for PHP that does not require any sort of templating system. Google is your friend.

  8. #7
    Senior Member
    Join Date
    Apr 2005
    Location
    Hatfield, England
    Posts
    855
    Member #
    9790
    Ah thanks a lot, i was goggling a few things but just couldn't find a phrase that brought helpful results


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