Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2002
    Posts
    3

    Unanswered: Formating data from a database

    I have a question that I think can be solved using ASp, but I'm not 100% sure so apologies in advance if it can't.

    On our website we have a form that, on submission, writes to our database. The form includes a textarea that the user can format how they choose, i.e add carriage returns etc. Obviously when this data is written to the database it is just one big line of text, thats not a problem. However I was wondering if it is possilbe for the data to be re-formatted into the same look as the user saw it when he/she submitted it when they retrieve it form the database.

    I was wondering if there was some kind of funciton that would substitute carriage reutrns for other characters, * for example and on retrieval from the database replace the * with a carriage return.

    Any help would be much appreciated

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    perhaps you could go and talk to whoever wrote the script that places the form field text into the database, because they can certainly tell you how carriage returns are handled

    it sounds like the carriage returns are being stripped out, and if that's the case, you could substitute a different character, and translate it on the way out again, except that you'll have a hard time picking a character that will never ever be entered by a user

    besides, the answer to your requirements is not to strip the carriage returns, just store them into the database field

    rudy
    http://rudy.ca/

  3. #3
    Join Date
    Sep 2002
    Posts
    17
    Carriage returns are not stripped by default. We have the same function on our site and have not problems with returning the data exactly as the user entered it.

    Is there some sort of special handling of the text that is occuring?
    David Williams
    Senior Jack of All Trades

  4. #4
    Join Date
    Oct 2002
    Posts
    1
    Originally posted by dwilliams
    Carriage returns are not stripped by default. We have the same function on our site and have not problems with returning the data exactly as the user entered it.

    Is there some sort of special handling of the text that is occuring?
    No, the fact is that the carriage return of the DB is different then the one of the HTML. Use the following function

    Replace(Fieldname,chr(13),"<br />").

    This replaces the DB carriage returns bij HTML carriage returns.

  5. #5
    Join Date
    Oct 2002
    Posts
    5
    There is a quick cheat if you only want to view the text on a web page - simply make the text fields on both pages (the entry page and the view page) the same width in characters e.g. 72.

    That way, the text shows it's original structure

Posting Permissions

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