PDA

View Full Version : Formating data from a database


pthompson2002
09-30-02, 07:50
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

r937
09-30-02, 10:10
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/

dwilliams
09-30-02, 17:34
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?

Caveman
10-08-02, 06:47
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.

chickenlover
10-16-02, 18:30
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