Skip navigation
This discussion is locked
Currently Being Moderated

Paragraphs don't display in database results (PHP)

May 26, 2009 4:34 PM

Unless you insert text into a database formatted with HTML tags, any line breaks will be ignored, resulting in a solid block of text when displayed in a browser. This is because browsers ignore whitespace and new lines in the underlying text.

 

The way to resolve this problem in a PHP page is to use the nl2br() function, which converts new lines into HTML <br /> tags. In Dreamweaver CS4, you can add this function to dynamic text through the Bindings panel as shown in the following screenshot:

nl2br.png

You can also add it to individual dynamic text objects by double-clicking the dynamic text listed in the Server Behaviors panel, and selecting Convert - New Lines to BRs in the Format field, as shown here:

nl2br_sb.png

In older versions of Dreamweaver, you need to wrap the dynamic text in nl2br() manually in Code view like this:

<?php echo nl2br($row_recordsetName['fieldName']); ?>
 

More Like This

  • Retrieving data ...

Bookmarked By (0)