Tutorials
Maintain linebreaks
To maintain the linebreaks in a piece of text when it is retrieved from your database, you need to tell Dreamweaver to replace them with their HTML equivalent.
If you are not utilising the paragraph tag, you may want to change the replacement of </p><p> in the following code snippets with <br />.
This is achieved with the following piece of code
VBScript
<%=Replace(rsName.Fields.Item("Column").Value,chr(13),"</p><p>")%>
JavaScript
<%=String(rsName.Fields.Item("Column").Value).replace(/\r/g, "</p><p>")%>
Cold Fusion (Thanks to Tom Muck - Basic UltraDev)
<cfoutput>#Replace(rsName.Column,chr(10), "</p><p>","all")#</cfoutput>
PHP (Thanks to Tom Muck - Basic UltraDev)
<?php echo str_replace("\n","</p><p>",$rsName->Fields("Column"))?>
Notes
- rsName is the name of your recordset.
- Column is the name of the column in your database that contains the memo field.
If you download my minisuite (here) - Server Behaviour 104 does this for you (In ASP/VBScript only) - no hand coding required!
Please be aware, the version in the minisuite replaces linebreaks with the <br> tag and not </p><p> tags!
© Copyright 2008 - robgt.com

