• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Displaying Paragraphs of text from MySQL Database

Guest
Apr 15, 2009 Apr 15, 2009

Copy link to clipboard

Copied

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?

TOPICS
Server side applications

Views

5.9K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Apr 15, 2009 Apr 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

...

Votes

Translate

Translate
LEGEND ,
Apr 15, 2009 Apr 15, 2009

Copy link to clipboard

Copied

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 />.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 15, 2009 Apr 15, 2009

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 15, 2009 Apr 15, 2009

Copy link to clipboard

Copied

There an additional solution not mentioned so far. I've used an extension that, when applied, maintains original formatting. It worked pretty well.

In the RobGT Suite, (it's an old extension and doesn't work with CS4 wish it worked in CS4) but here's the code that it produces:

Example ASP vbscript so you'd need to translate to php.

<%=Replace(rsRecordsetname.Fields.Item("ColumnNameInRecordset").Value,chr(13),"<br>")%>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 15, 2009 Apr 15, 2009

Copy link to clipboard

Copied

That ASP script simply converts newline characters to <br> tags. PHP uses a built-in function, nl2br(), whereas the ASP one relies on using the character code to search for a newline (13).

Dreawmeaver handles it natively in PHP without the need for an extension, mainly because I lobbied for it to be added to the Format menu in the Dynamic Text dialog box. I don't know if similar functionality was added to the Format menu for ASP.

Why nl2br()? New line (nl) to (2) break (br).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 15, 2009 Apr 15, 2009

Copy link to clipboard

Copied

LATEST

It's probably not updated as ASP Classic is a "Dead Language," relatively speaking.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 15, 2009 Apr 15, 2009

Copy link to clipboard

Copied

Hi LArtJunky,

Thanks for your reply but I am going for the HTML option as it will allow my client more freedom to make the page look better.  Give him a chance to hyperlink names etc and highlight different areas. So thanks anyway.

Lloyd

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines