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?
You have two options:
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
...Copy link to clipboard
Copied
You have two options:
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 />.
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
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>")%>
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).
Copy link to clipboard
Copied
It's probably not updated as ASP Classic is a "Dead Language," relatively speaking.
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