₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,330,985 members, 8,448,107 topics. Date: Sunday, 19 July 2026 at 06:50 PM

Toggle theme

PHP: How Do I Add Paragraph When I Make A Post Through Text Field - Webmasters - Nairaland

Nairaland ForumScience/TechnologyWebmastersPHP: How Do I Add Paragraph When I Make A Post Through Text Field (494 Views)

1 Reply

PHP: How Do I Add Paragraph When I Make A Post Through Text Field by Raylight2(op): 5:45pm On Jun 16, 2016
Please, I am currently developing a website. when I include a paragraph (white space) between two sentences and send to the database, it's ignored when selected from the database back to the browser. please, what should I do?

looking forward to hear from you please.
Re: PHP: How Do I Add Paragraph When I Make A Post Through Text Field by ukorsimplicity(m):
What you need is a WYSIWYG editors... you can checkout tinyMCE or textboxio ..

If TEXT EDITORS are overkill for your project, you can use the php nl2br() function ( http://php.net/nl2br ). like this

<?php

echo nl2br($_POST['textarea']);

?>
or you can use this code i borrowed from stack Over Flow ( http://stackoverflow.com/questions/4523961/paragraphs-in-textarea )

<?php

$textarea = $_POST['textarea'];

$newarr = explode("\n",$textarea);

foreach($newarr as $str) {

echo "<p>".$str."</p>";

}
?>
Happy coding...
Re: PHP: How Do I Add Paragraph When I Make A Post Through Text Field by Raylight2(op): 10:36pm On Jun 16, 2016
Thanks so much bro. I'll try it out.
1 Reply

How Do I Add The Google Adsense Code To My Website?How Do I Add "Like Me On Facebook" On My Blog?How Can I Add Debit/credit Card Payment On My Site234

If You A A Good Web Developer And You Need Clients Contact MeWhere To Get Free Hosting For Your BlogAbout Google Adsense