PDA

View Full Version : Format Text from DB


Ravingmonkey
04-05-2009, 05:16 PM
Hello All,

I have a report I am pulling from a MySQL DB and the field is a pure text field, which may contain 100's of words, the user inserts the paragraph breaks in their submit form, but I am getting long monolithic text on my PhP page when I present the report to readers.

How do I tell PhP to format the text per the </br> in the field? I know I could do this with ASP, but can't find anything that tells me how to do this with PhP.

Thanks in advance for your help!

RM

davidj
04-05-2009, 07:57 PM
nl2br function

use this before the user enters the data into the db

$newtext = nl2br($formfieldtext);

insert statement next using the $newtext var

this replaces \cr \r \n to <br />

Ravingmonkey
04-05-2009, 08:53 PM
How easy was that! Perfect thanks! RM