Skip to main content
April 15, 2009
Answered

Displaying Paragraphs of text from MySQL Database

  • April 15, 2009
  • 1 reply
  • 6264 views

Hi All,

I have a small database used to store news articles and display them on a site.  However what is happening is that the news articles are not being displayed with the paragraph information that the is input.


When the page is displayed it just diplays the text in one block even though I can see the carriage returns if I view the database in phpMyAdmin.

Can anyone assist please?

This topic has been closed for replies.
Correct answer David_Powers

You have two options:

  • Save your articles with HTML embedded (use something like FCKEditor or TinyMCE to add HTML features to your text area on the input form)
  • Put two new lines between each paragraph when entering text, and use the PHP function nl2br() when displaying the output

Dreamweaver CS4 (and possibly CS3) will insert nl2br() around dynamic text if you double-click the dynamic text object in the Server Behaviors panel and select Convert - New Lines to BRs from the format menu. This wraps the dynamic text object like this:

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

nl2br() converts newline characters to <br />.

1 reply

David_Powers
David_PowersCorrect answer
Inspiring
April 15, 2009

You have two options:

  • Save your articles with HTML embedded (use something like FCKEditor or TinyMCE to add HTML features to your text area on the input form)
  • Put two new lines between each paragraph when entering text, and use the PHP function nl2br() when displaying the output

Dreamweaver CS4 (and possibly CS3) will insert nl2br() around dynamic text if you double-click the dynamic text object in the Server Behaviors panel and select Convert - New Lines to BRs from the format menu. This wraps the dynamic text object like this:

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

nl2br() converts newline characters to <br />.

April 15, 2009

Hi David,

Thanks for taking the time to reply to my question. I did look at using a HTML editor but those I found were lets just say light weight compared to the one you have suggested, so thanks for that. I know that will enhance the site as I wanted.

However I am not sure about intergrating the ckeditor into my existing code. I will give it a go however and just may have to shout for help again.

Thanks for you help.

Best,

Lloyd