Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Sep 2012
    Posts
    87
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Question Database table data not being displayed in right format on browser

    The contents of a mysql database table are being displayed as one continuous story without paragraphing (i.e. not being displayed in paragraphs). How do I correct the anomaly? Do I change the data types of the column or what? Note that the data is inserted into the database table via a html form. PLEASE HELP!

  • #2
    New Coder
    Join Date
    Sep 2012
    Posts
    71
    Thanks
    0
    Thanked 8 Times in 8 Posts
    It's likely that you'll have to format the output ... in HTML newlines are just treated like a space character (and multiple spaces are condensed to a single space).

    In PHP you could use nl2br...
    http://php.net/manual/en/function.nl2br.php

    You could also keep a little more control with str_replace...
    http://ca2.php.net/manual/en/function.str-replace.php

    An example, leaving blank lines for double newlines:

    PHP Code:
    $data str_replace("\r","",$data);               // collapse \r\n\r\n or \n\r\n\r
    $data str_replace("\n\n","<br /><br />",$data);
    echo 
    $data


  •  

    Posting Permissions

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