User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ColdFusion section within the Web Development category of DaniWeb, a massive community of 373,364 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,649 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ColdFusion advertiser:
Views: 750 | Replies: 2 | Solved
Reply
Join Date: Mar 2008
Posts: 2
Reputation: Jeanioz is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Jeanioz Jeanioz is offline Offline
Newbie Poster

Question Using #parameter# string of databases

  #1  
Mar 20th, 2008
Hello, I am newbie in Coldfusion development and I have a question:

I must make a application where I have to use a parameter in a database (and not written in the code).

Example: I have to show a text of a table with a "subtext" of other table. So I do this:

Table1:
id = 1
text = "This is an #qry_2.subtext#"

Table2:
id = 1
subtext = "example"

<cfquery datasource="#application.DSN#" name="qry_1">
      SELECT text FROM table1 WHERE id = 1
   </cfquery>

<cfquery datasource="#application.DSN#" name="qry_2">
      SELECT subtext FROM table2 WHERE id = 1
   </cfquery>

<cfoutput>#qry_1.text#</cfoutput>

But only appear "This is an #qry_2.subtext#", and not "This is an example". The Coldfusion can“t read the ## of the string of database and put the subtext of table2.

There is a solution to make the Coldfusion read a ## parameter of a database with process it?

Obs.: Sorry my poor english. I am brazilian.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2005
Location: Downingtown
Posts: 45
Reputation: hinde is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 2
hinde hinde is offline Offline
Light Poster

Re: Using #parameter# string of databases

  #2  
Mar 22nd, 2008
Sorry, but what you have there is not going to work. Trying to have dynamic content inside text stored in a database table is usually done with percent-sign delimited placeholders (or whatever your delimiter of choice happens to be). Here is an example:

First of all replace the text "#qry_2.subtext#" in table1 with "%placeholder%".
Store the value of qry_1.text in a temporary variable. I usually go with strTemp.
Replace the instances of %placeholder% with the value of qry_2.subtext.
Example:
<cfset strTemp = ReplaceNoCase(strTemp,"%placeholder%",qry_2.subtext,"all")>
Output strTemp.

I have used this technique on numerous occasions in the past and it always works for me.
Reply With Quote  
Join Date: Mar 2008
Posts: 2
Reputation: Jeanioz is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Jeanioz Jeanioz is offline Offline
Newbie Poster

Re: Using #parameter# string of databases

  #3  
Mar 24th, 2008
The Replace function works! Thank you!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb ColdFusion Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the ColdFusion Forum

All times are GMT -4. The time now is 2:44 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC