Professional Web Applications Themes

format display from database field - Macromedia ColdFusion

:clock;:rose; The database saves the text from the textarea field of the form correctly. I can format the paragraph breaks okay that were entered in the form, but the line breaks don't format correctly. It displays as a continuous line with the preceding text. I was given a tip that SQL uses an ASCII character to identify the line breaks when the text is saved in the db. Is there a way to look for that character and somehow put a <br> tag in to serve as the line break when the text is displayed in the web page from ...

  1. #1

    Default format display from database field

    :clock;:rose;

    The database saves the text from the textarea field of the form correctly. I
    can format the paragraph breaks okay that were entered in the form, but the
    line breaks don't format correctly. It displays as a continuous line with the
    preceding text.

    I was given a tip that SQL uses an ASCII character to identify the line breaks
    when the text is saved in the db. Is there a way
    to look for that character and somehow put a <br> tag in to serve as the line
    break when the text is displayed in the web page from the db? Is there another
    way/

    All ideas welcome. I need to work this out by tomorrow.

    Thanks in advance!

    Joy

    JoyRose Guest

  2. #2

    Default Re: format display from database field

    I've used the REREPLACE function in similar situations. Chr(10) is the ASCII code for the equivalent to BR.

    <cfset NewContents = REReplace(Contents, Chr(10), "<br>", "ALL")>
    mkane1 Guest

  3. #3

    Default Re: format display from database field

    Joy,

    Mkane1 is correct, however, you do not need the regular expression replace
    function, and you should perhaps also check for the carriage return character.

    <CFSet crlf = chr(13) & chr(10)>
    <CFSet NewContents = Replace(Contents,crlf,"<br>","ALL")>

    HTH
    Swift

    Swift Guest

  4. #4

    Default Re: format display from database field

    Thank you so much. Perfect as written!:D
    JoyRose Guest

  5. #5

    Default Re: format display from database field

    My problem is the opposite, but related. I post a form with a text field. If
    there is a chr(10) or a chr(13) in the field then it takes the chr(13) and make
    it chr(13)chr(10). So basically it puts 2 line breaks in when there should be
    only one. I'm using CF 7 on a Windows 2003 server. I have the latest hotfixes
    installed.

    zbis12 Guest

Similar Threads

  1. Replies: 11
    Last Post: September 12th, 09:10 PM
  2. Replies: 0
    Last Post: January 2nd, 09:47 PM
  3. i want to display all the data in the database to the text field
    By binglee17@gmail.com in forum Macromedia Director 3D
    Replies: 0
    Last Post: June 23rd, 05:57 AM
  4. Date display format
    By erickia in forum Dreamweaver AppDev
    Replies: 16
    Last Post: May 17th, 07:18 PM
  5. Data format and display
    By Josué Maldonado in forum PostgreSQL / PGSQL
    Replies: 3
    Last Post: January 22nd, 07:58 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139