how do I display <br> where database record has new paragraph?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • NotGiven

    how do I display <br> where database record has new paragraph?

    I have a form that inserts records in a database. When I display records,
    the paragraphs don't show up.

    I am using dreamweaver MX, PHP, and MySQL.


  • Chris Hope

    #2
    Re: how do I display &lt;br&gt; where database record has new paragraph?

    NotGiven wrote:
    [color=blue]
    > I have a form that inserts records in a database. When I display records,
    > the paragraphs don't show up.
    >
    > I am using dreamweaver MX, PHP, and MySQL.[/color]

    Use nl2br() - http://www.php.net/nl2br

    --
    Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/

    Comment

    • Michael Fesser

      #3
      Re: how do I display &lt;br&gt; where database record has new paragraph?

      .oO(NotGiven)
      [color=blue]
      >I have a form that inserts records in a database. When I display records,
      >the paragraphs don't show up.
      >
      >I am using dreamweaver MX, PHP, and MySQL.[/color]

      You could use nl2br() to replace the linebreaks with HTML-linebreaks,
      but the better solution would be to keep the paragraphs, i.e. to replace
      double linebreaks with </p><p> (easy to do with preg_replace() or
      str_replace()) and enclose the entire string with <p></p>.

      For a stored string

      paragraph 1\n\nparagraph 2

      the result would be

      <p>paragraph 1</p><p>paragraph 2</p>

      Micha

      Comment

      • NotGiven

        #4
        thanks for your help!


        "NotGiven" <noname@nonegiv en.net> wrote in message
        news:EViGc.1457 6$w56.14174@big news1.bellsouth .net...[color=blue]
        > I have a form that inserts records in a database. When I display records,
        > the paragraphs don't show up.
        >
        > I am using dreamweaver MX, PHP, and MySQL.
        >
        >[/color]


        Comment

        Working...