# Paragraphs in php from mysql

**URL:** <https://forum.kirupa.com/t/paragraphs-in-php-from-mysql/64813>\
**Category:** Uncategorized\
**Created:** [September 20, 2004, 10:22am UTC](https://forum.kirupa.com/t/paragraphs-in-php-from-mysql/64813 "2004-09-20T10:22:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![alapimba](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@alapimba](https://forum.kirupa.com/u/alapimba)\
**Post date:** [September 20, 2004, 10:22am UTC](https://forum.kirupa.com/t/paragraphs-in-php-from-mysql/64813/1 "2004-09-20T10:22:22Z")

</div>

hello  
i have a mysql database and the text fields will be to appear on a php page.  
everything is working fine except the paragraphs… what i have to do so i can add paragraphs in a mysql entry and it appear on the php?  
Thx in advance

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 20, 2004, 10:47am UTC](https://forum.kirupa.com/t/paragraphs-in-php-from-mysql/64813/2 "2004-09-20T10:47:48Z")

</div>

you have to use the nl2br() function. (new line 2 break).

It converts the new line character in text fields into \<br\> tags for html. When you draw the information from the database and output it to the page format the text by using the function:

```php

$text = nl2br($text);

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 20, 2004, 3:09pm UTC](https://forum.kirupa.com/t/paragraphs-in-php-from-mysql/64813/3 "2004-09-20T15:09:37Z")

</div>

sweet, i needed to know that one too;)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 20, 2004, 6:35pm UTC](https://forum.kirupa.com/t/paragraphs-in-php-from-mysql/64813/4 "2004-09-20T18:35:41Z")

</div>

Now where in the HELL was that in my PHP and MySQL for dynamic websites book… oh well, live and learn.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 20, 2004, 8:47pm UTC](https://forum.kirupa.com/t/paragraphs-in-php-from-mysql/64813/5 "2004-09-20T20:47:23Z")

</div>

thanks ironikart 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 20, 2004, 9:43pm UTC](https://forum.kirupa.com/t/paragraphs-in-php-from-mysql/64813/6 "2004-09-20T21:43:49Z")

</div>

> Now where in the HELL was that in my PHP and MySQL for dynamic websites book… oh well, live and learn.

lol im using the same book right now as reference and i didnt see it either, dunno if i missed it or ullman didnt put it in there. I really like that book though;)
