RollinNow
asked on
Expand variable embedded inside an sql table
How can I expand a variable which is embedded within a table column, itself expanded by a cfquery output?
A query, FilesInfo.description, is enclosed with cfoutput tags (see below). This is a column inside my sql table, data type varchar.
I want to edit the contents of FilesInfo.description and insert a variable in the middle of the text. When FilesInfo.description is expanded, the new variable is also expanded.
I guess you can see this as a variable within a variable, and it seems to me I read one cannot do this. But I'm hoping there is another way.
Here's the contents of "filesInfo.description".
"Story of a group of filmmakers traveled to Skull Island. <cfoutput>#variable#</cfou tput> They intended to investigate legends of a giant gorilla named Kong."
The problem is when expanded, #FilesInfo.description# displays my embedded variable name like this:
"This is the story of a group of explorers and documentary filmmakers traveled to Skull Island. #variable# There they intend to investigate legends of a giant gorilla named Kong."
The variable is not expanded. Is there a workaround or a different method to do this without having to change my database design?
<cfquery name="FilesInfo" datasource="Library">
select description
from areas
where area_id = #area_id#
</cfquery
<cfoutput>#FilesInfo.descr iption#</c foutput>
- Georgia
A query, FilesInfo.description, is enclosed with cfoutput tags (see below). This is a column inside my sql table, data type varchar.
I want to edit the contents of FilesInfo.description and insert a variable in the middle of the text. When FilesInfo.description is expanded, the new variable is also expanded.
I guess you can see this as a variable within a variable, and it seems to me I read one cannot do this. But I'm hoping there is another way.
Here's the contents of "filesInfo.description".
"Story of a group of filmmakers traveled to Skull Island. <cfoutput>#variable#</cfou
The problem is when expanded, #FilesInfo.description# displays my embedded variable name like this:
"This is the story of a group of explorers and documentary filmmakers traveled to Skull Island. #variable# There they intend to investigate legends of a giant gorilla named Kong."
The variable is not expanded. Is there a workaround or a different method to do this without having to change my database design?
<cfquery name="FilesInfo" datasource="Library">
select description
from areas
where area_id = #area_id#
</cfquery
<cfoutput>#FilesInfo.descr
- Georgia
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
CodeParadise,
The evaluate function didn't work for me either, but your solution does. I should have thought of it. Makes sense. However, to get it to work for me, I had to do this:
<cfset newText = Replace(FilesInfo.descript ion, "babygunk", "#var#", "ALL")>
babygunk is just some text I know I'll never use so it's unique and does not need to be a set variable. It replaces babygunk with my defined variable, var.
Thanks for your help, and thanks, pegarm, for the attempt.
- Georgia
The evaluate function didn't work for me either, but your solution does. I should have thought of it. Makes sense. However, to get it to work for me, I had to do this:
<cfset newText = Replace(FilesInfo.descript
babygunk is just some text I know I'll never use so it's unique and does not need to be a set variable. It replaces babygunk with my defined variable, var.
Thanks for your help, and thanks, pegarm, for the attempt.
- Georgia
<cfquery name="FilesInfo" datasource="Library">
select description
from areas
where area_id = #area_id#
</cfquery
<cfoutput>#evaluate(FilesI