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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

outputting a list

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hello,
Can somebody please help me?

This may sound real stupid but

I have a query in which my SELECT elements are in a list
How Can I output exactly those list elements from my query, since i don't know which fields are in the list and i can't just put my list between output tags.

I tried looping with arays and stuff
Here's my code:


<cfquery name=&quot;qGetViews&quot; datasource=&quot;datasource&quot; dbtype=&quot;ODBD&quot; maxrows=&quot;1&quot;>
SELECT #Session.Primarykey# AS Primarykey,
<cfset QuerElements = #Session.ViewFields#>
<cfloop from=&quot;1&quot; to=&quot;#ListLen(Session.ViewFields)#&quot; index=&quot;counter&quot;>
<cfset Session.aQuElements[teller] = #ListFirst(QuerElements)#>
<cfset QuerElements = #ListRest(QuerElements)#>
#Session.aQuElements[teller]# AS GetField#teller# <cfif teller lt #ListLen(Session.FormVeldenZien)#>,</cfif>
</cfloop>
FROM tablename
ORDER BY #Session.Primkey# DESC
</cfquery>

Now if the list Session.ViewFields contains 3 elements
I want to dynamicly output Getfield1,Getfield2 and Getfield3,
but i can't do this in a loop .

Please Help
tnx
 
Is this what you were trying to do?

<cfquery name=&quot;qGetViews&quot; datasource=&quot;datasource&quot; dbtype=&quot;ODBD&quot; maxrows=&quot;1&quot;>
SELECT #Session.Primarykey# AS Primarykey,
<cfloop LIST=&quot;#Session.ViewFields#&quot; index=&quot;vItem&quot;>
#vItem# AS GetField#vItem#<cfif VARIABLES.vItem IS NOT ListLast(Session.ViewFields)>,</cfif>
</cfloop>
FROM tablename
ORDER BY #Session.Primkey# DESC
</cfquery>
- tleish
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top