Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL UPDATE with ColdFusion - inserting HTML???

Status
Not open for further replies.

rockyroad

Programmer
Feb 22, 2003
191
US
Hi,

I need to run a query that will update a DB record with a long, rather complex string of HTML. Here is what I am after ---
Code:
<cfset String ="
<div id="tabs"> 
<ul id="tablist"> 
<li><a href="#tabs" onclick="expandcontent('sc1', this)">one</a></li> 
<li><a href="#tabs" onclick="expandcontent('sc2', this)">two</a></li> 
<li><a href="#tabs" onclick="expandcontent('sc3', this)">three</a></li> 
<li><a href="#tabs" onclick="expandcontent('sc4', this)">four</a></li> 
</ul> 
</div>
">

<cfquery name="Update" datasource="#Application.Datasource#">
UPDATE Table
SET Content = #HTMLEditFormat(String)#
		  WHERE ID = 2
</cfquery>

This produces and error in the CFSET.

There must be a relatively easy way to handle this problem?

Any help will be much appreciated!

Thanks

RR [yinyang]
 
Yep i'll second with r on this one.

When dealing with large lumps of datalike that do somthing like this.

Code:
<cfsavecontent variable="theHtmlCode">
<div id="tabs"> 
<ul id="tablist"> 
<li><a href="#tabs" onclick="expandcontent('sc1', this)">one</a></li> 
<li><a href="#tabs" onclick="expandcontent('sc2', this)">two</a></li> 
<li><a href="#tabs" onclick="expandcontent('sc3', this)">three</a></li> 
<li><a href="#tabs" onclick="expandcontent('sc4', this)">four</a></li> 
</ul> 
</div>
</cfsavecontent>

<cfquery name="Update" datasource="#Application.Datasource#">
UPDATE Table
SET Content = #HTMLEditFormat(theHtmlCode)#
          WHERE ID = 2
</cfquery>

I've not used savecontent in this way before, but I do use it a hell of a lot for other applications and its very simple.

Rob
 
Just out of interest,

Is there really a requirement to save the HTML into the database?

Rob
 
Is there really a requirement to save the HTML into the database?
where else would you save it? you would try to assemble it around the salient nuggets of information on the fly? in the above example, these bits are tabs, tablist, expandcontent, sc1/one, sc2/two, sc3/three, sc4/four -- how would you save those pieces of information and still make it easy to deliver html to the browser?


r937.com | rudy.ca
 
Well thats a difficult question to ask rudy without knowing the proper application for the HTML,

My personal preferance would be to avoid saving HTMl into the database unless it was an absolute nececity, i've always seen the database as a place for storeing my raw data, any HTMl formatting should be parsed before delivery to the browser.

There are a hole host of possibilities, includes, custom tags and suchlike.

I just struggle to understand the need to save that content into a database when it could sit quite nicely inside a CFM file, and then be wrapped around any content that it needs to be wrapped around.

Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top