Embed HTML in database fields?
I struggled all weekend with this, and didn't get anywhere, so I'm guessing it can't be done...
I want to embed HTML tags into my database, but Access doesn't seem to like this. For example, I want to put "blah blah <font color="red">Important stuff</font>" into a text or memo field and then do "save as HTML" on the table, query or form. But all the tags get converted to the "ampersand-ltfont=..." type of format. [had to spell out "ampersand" because the bb software does conversion! but you guys know what I'm getting at here...right?]
I'm guessing Access will continue to do this when I get farther along in development and start saving to ASP files instead of static HTML?
Or is there some way to tell Access to not strip the tags out of certain fields? They are preserved if I save as a text file, but then I don't have the HTML table stuff I need. I could alternatively run the Access output through text editor doing a global search & replace, but there may be """s and such that are not part of tags and *shouldn't* be converted.
Help?
(If I'm completely out of luck here, I'll probably upgrade my future site to ColdFusion, which I use at work.)
Thanks in advance...as my site gets further along in development, I think this board will be a great reasource!
[This message has been edited by KLWong (edited 17 April 2000).]
[This message has been edited by KLWong (edited 17 April 2000).]
Kristen
http://www.RewardsLookup.com and
http://www.cancerdrugfeedback.net still under early development
Personal page:http://www.isd.net/kwong/kristen.html
Peter J. Boettcher posted this at 04:35 — 17th April 2000.
They have: 812 posts
Joined: Feb 2000
KLWong,
Are you using ASP? If your are just use Server.HTMLEncode(Request.Form("FormField"))
This should preserve everything.
It's ok if it looks like gibberish in the database, when you pull it back out it will be in the proper format (source code).
Regards,
Peter J. Boettcher
[This message has been edited by Peter J. Boettcher (edited 17 April 2000).]
PJ | Are we there yet?
pjboettcher.com
KLWong posted this at 17:38 — 17th April 2000.
They have: 135 posts
Joined: Apr 2000
Well, sort of along the lines of "start with what you know", I've so far been exporting my tables to static HTML files. Also since I do much of my development during "dead times" at work, and I'm not allowed to install any software on their PC, I've not started trying ASP output yet. (Can't install Personal Web Server to view the pages generated.)
I did try the "Save as ASP" option on my query and then looked at the text output with an editor. I see it put out <%=Server.HTMLEncode(rs.Fields("Description").Value)%> without me doing anything special. Will this output allow my embedded HTML tags to be properly interpreted (rather than converted)?
Thanks, Peter!
Kristen
http://www.RewardsLookup.com and
http://www.cancerdrugfeedback.net still under early development
Personal page:http://www.isd.net/kwong/kristen.html
Peter J. Boettcher posted this at 19:31 — 17th April 2000.
They have: 812 posts
Joined: Feb 2000
KLWong,
I'm a little confused, what do you want to use the save html for? Are you pulling it out of the database to display it in a web page or are you using it for something else?
The Server.HTMLEncode method will take a string and convert it, so spaces will turn to "*nbsp" etc., but if you're using this for display in a web page then that is fine since it will display perfect. So in theory if I took the output of a Server.HTMLEncode string and pasted it into a web page it would display the same as the source.
Regards,
Peter J. Boettcher
[This message has been edited by Peter J. Boettcher (edited 17 April 2000).]
[This message has been edited by Peter J. Boettcher (edited 17 April 2000).]
PJ | Are we there yet?
pjboettcher.com
KLWong posted this at 21:52 — 17th April 2000.
They have: 135 posts
Joined: Apr 2000
Sorry I'm being so confusing!
I'm eventually going to put up a searchable database on my website (no point in giving you a URL here, hosting company is dragging their feet getting it set up). However, my plan is to first put up static HTML pages which I will extract from the database first, while I get the whole thing set up. Then I'll convert it to the dynamic, searchable site that is my ultimate plan.
Trying to take one step at a time here, since it's my first site (beyond posting kid pictures!).
I'm trying to embed some HTML into the database because I want my ongoing site maintenance to be 90% database updates while the pages themselves are rarely changed.
Clear as mud?
(I will post the URL as soon as it works!)
Kristen
http://www.RewardsLookup.com and
http://www.cancerdrugfeedback.net still under early development
Personal page:http://www.isd.net/kwong/kristen.html
Ralph Slate posted this at 14:58 — 18th April 2000.
They have: 32 posts
Joined: Mar 2000
I did the same thing; however instead of embedding the HTML in the database, I embedded it in the "export" program.
That way if I needed to change something, instead of doing a database change that might have to update a few thousand records, I updated a couple of lines of code.
There are definitely instances when I embedded the HTML in the database; usually when storing "articles". That was easier. But if the data column contains pure data (a number, for example), it might be easier to put the HTML in the program that generates your page.
Ralph
http://www.hockeydb.com
http://www.hockeydb.com
Peter J. Boettcher posted this at 19:21 — 18th April 2000.
They have: 812 posts
Joined: Feb 2000
Ralph,
That's an option as well, but I think all the HTML would have to conform to roughly the same sort of output otherwise you would be changing a lot more than 2 lines of code.
If the HTML you're saving is all completely different from each other (not related data or structure wise) then this would be hard to do.
Regards,
Peter J. Boettcher
PJ | Are we there yet?
pjboettcher.com
Ralph Slate posted this at 19:56 — 18th April 2000.
They have: 32 posts
Joined: Mar 2000
For example, if you have a membership list with names, addresses, etc. in it, I'd suggest storing the data as:
Name: John Smith
Address: 1 Center St.
Town: Anytown
Country: USA
Rather than:
Name: <B>John Smith</B>
Address: <I>1 Center St.</I>
Town: <FONT SIZE=-1>Anytown</FONT>
Country: <H3>USA</H3>
There is a widespread notion that content and formatting should be separate; not only in coding to HTML 4.0 standards, but also in database theory.
I don't know what you're using to generate your static web pages, but if you want to generate a simple page for each member, you would do this:
print <B>Name</B>
print <I>Address</I>
print <FONT SIZE=-1>Town</FONT>
print <H3>Country</H3>
Now lets say you want to change your Town to be normal sized; simply change your program to remove the "size=-1" line. You don't have to update all the records in your database.
This works if your data is atomic in nature -- in other words, one piece of data per database column. If you're storing full text in the database, then you have a different problem which probably requires storing HTML tags. But perhaps you want to store style markers instead so that you can change the styles in your stylesheet which will have the effect of changing the presentation without having to change your data.
Ralph
http://www.hockeydb.com
http://www.hockeydb.com
Peter J. Boettcher posted this at 20:21 — 18th April 2000.
They have: 812 posts
Joined: Feb 2000
Ralph,
I agree, your example clearly illustrates the benefits, I'm just not sure how structured KLWong's data is.
If it's just a matter of a handful or two of pages I would probably stick with the database embed (especially if your data isn't structured)
Regards,
Peter J. Boettcher
PJ | Are we there yet?
pjboettcher.com
KLWong posted this at 06:33 — 21st April 2000.
They have: 135 posts
Joined: Apr 2000
Finally back after beind unable to connect for a couple of days...arghh.
Thanks all for your comments. I finally went out today and bought an ASP book. Looks like it should work, no problem. Also looks like ASP is very similar to ColdFusion in functionality, so it may be easy to pick up quickly.
[What I've got is a large "freeform" memo field for each paragraph of text, and want to include formatting stuff, like bold, underline and color, using the HTML tags in the actual database for ease of output.]
Thanks again!
Kristen
http://www.RewardsLookup.com and
http://www.cancerdrugfeedback.net still under early development
Personal page:http://www.isd.net/kwong/kristen.html
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.