Jump to content

Keeping paragraphs etc.


jcstanley

Recommended Posts

Hi
I am currently copying data into a database from an existing page on my site.

When the text is entered into a text area on a form it is paragraphed.  But when viewed on the page wich retrieves the data from the database it is just one continuous chunk of text.

Is there any way of keeping the paragraphs etc? (A similar format to entering a post on this site would be ideal)

Thanks
Link to comment
https://forums.phpfreaks.com/topic/24121-keeping-paragraphs-etc/
Share on other sites

What are you using to view the data in the database?

When displaying the data back to a browser, the browser does not interpret the newline character. To be able to show the text correctly use the [url=http://www.php.net/nl2br]nl2br()[/url] function.

Example:
[code]<?php
$text =  "this text has \nnewline\n characters in it";
echo nl2br($text);
?>[/code]

Ken

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.