6 Replies - 1603 Views - Last Post: 19 July 2010 - 02:02 PM Rate Topic: -----

#1 bucsfan68  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 08-June 10

ColdFusion DB Query not displaying properly

Posted 08 June 2010 - 12:15 PM

Kind of stumped here. I'm new to ColdFusion. The query that I have set, is pulling the correct number of records, but the output to the screen is #qryGetFiles1.docTitle# (repeated for the number of recordes), not the actual document title.


<cfquery name="qryGetFiles1" datasource="#datasource#">
	SELECT		docID, docTitle, fileName, docLocation, fileLocation, fileURL, fileGroup, fileCategory, summary, lastUpdate, docType, status
	FROM		tblDocuments
	WHERE		(docType in ('13'))
	ORDER BY	docTitle
</cfquery>

<cfloop query="qryGetFiles1">	
	<cfif qryGetFiles1.fileURL NEQ "">
		<li><a href="#qryGetFiles1.fileURL#">#qryGetFiles1.docTitle#</a></li>
	<cfelse>
		<li><a href="#qryGetFiles1.docLocation##qryGetFiles1.fileName#">#qryGetFiles1.docTitle#</a></li>
	</cfif>
</cfloop>




Is This A Good Question/Topic? 0
  • +

Replies To: ColdFusion DB Query not displaying properly

#2 Craig328  Icon User is offline

  • I make this look good
  • member icon

Reputation: 1926
  • View blog
  • Posts: 3,471
  • Joined: 13-January 08

Re: ColdFusion DB Query not displaying properly

Posted 08 June 2010 - 12:17 PM

Replace your cfloop tag with a cfoutput tag like so:
<cfoutput query="qryGetFiles1">...</cfoutput>


That should get you where you want to be.

Good luck!
Was This Post Helpful? 1
  • +
  • -

#3 bucsfan68  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 08-June 10

Re: ColdFusion DB Query not displaying properly

Posted 08 June 2010 - 12:22 PM

View Postbucsfan68, on 08 June 2010 - 11:15 AM, said:

Kind of stumped here. I'm new to ColdFusion. The query that I have set, is pulling the correct number of records, but the output to the screen is #qryGetFiles1.docTitle# (repeated for the number of recordes), not the actual document title.


<cfquery name="qryGetFiles1" datasource="#datasource#">
	SELECT		docID, docTitle, fileName, docLocation, fileLocation, fileURL, fileGroup, fileCategory, summary, lastUpdate, docType, status
	FROM		tblDocuments
	WHERE		(docType in ('13'))
	ORDER BY	docTitle
</cfquery>

<cfloop query="qryGetFiles1">	
	<cfif qryGetFiles1.fileURL NEQ "">
		<li><a href="#qryGetFiles1.fileURL#">#qryGetFiles1.docTitle#</a></li>
	<cfelse>
		<li><a href="#qryGetFiles1.docLocation##qryGetFiles1.fileName#">#qryGetFiles1.docTitle#</a></li>
	</cfif>
</cfloop>




Thank you! That worked.
Was This Post Helpful? 0
  • +
  • -

#4 Craig328  Icon User is offline

  • I make this look good
  • member icon

Reputation: 1926
  • View blog
  • Posts: 3,471
  • Joined: 13-January 08

Re: ColdFusion DB Query not displaying properly

Posted 08 June 2010 - 12:37 PM

N/P. Welcome to D.I.C.
Was This Post Helpful? 0
  • +
  • -

#5 cyb1n  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 27
  • Joined: 08-May 09

Re: ColdFusion DB Query not displaying properly

Posted 19 July 2010 - 01:11 PM

You can also enclose the cfloop block in cfoutput tags to get the same results.

<cfoutput>
<cfloop query="qryName">
(variables to be evaluated)
</cfloop>
</cfoutput>


Was This Post Helpful? 1
  • +
  • -

#6 Craig328  Icon User is offline

  • I make this look good
  • member icon

Reputation: 1926
  • View blog
  • Posts: 3,471
  • Joined: 13-January 08

Re: ColdFusion DB Query not displaying properly

Posted 19 July 2010 - 01:52 PM

View Postcyb1n, on 19 July 2010 - 12:11 PM, said:

You can also enclose the cfloop block in cfoutput tags to get the same results.

<cfoutput>
<cfloop query="qryName">
(variables to be evaluated)
</cfloop>
</cfoutput>




Yep, you could do that as well. Once upon a time, way back in the early CF days there was a marked performance slowdown using CFLOOP to output query result sets. When CF got to 4.5 and then again to MX that difference narrowed considerably as to be non-existent. They perform pretty much the same these days (unless CF9 has made any significant changes but I haven't heard anything like that).

The only thing it comes down to these days is code readability and size. The example you showed requires the use of CFLOOP in addition to CFOUTPUT so it's extra tags which normally means extra processing. Probably never enough to notice but it likely still exists some. It IS another way to do the same thing and it's really more a matter of personal preference/habit.

Good point.
Was This Post Helpful? 0
  • +
  • -

#7 cyb1n  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 27
  • Joined: 08-May 09

Re: ColdFusion DB Query not displaying properly

Posted 19 July 2010 - 02:02 PM

View PostCraig328, on 19 July 2010 - 07:52 PM, said:

Yep, you could do that as well. Once upon a time, way back in the early CF days there was a marked performance slowdown using CFLOOP to output query result sets. When CF got to 4.5 and then again to MX that difference narrowed considerably as to be non-existent. They perform pretty much the same these days (unless CF9 has made any significant changes but I haven't heard anything like that).

The only thing it comes down to these days is code readability and size. The example you showed requires the use of CFLOOP in addition to CFOUTPUT so it's extra tags which normally means extra processing. Probably never enough to notice but it likely still exists some. It IS another way to do the same thing and it's really more a matter of personal preference/habit.

Good point.


Excellent points Craig. I was not aware of the performance issues in the older versions of ColdFusion. I've only worked with ColdFusion 7 and up, although most extensively with ColdFusion 8.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1