Welcome to Dream.In.Code
Getting Help is Easy!

Join 109,716 Programmers for FREE! Ask your question and get quick answers from experts. There are 2,148 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Looping over query details

 
Reply to this topicStart new topic

Looping over query details

oldspice
post 18 Sep, 2007 - 11:53 AM
Post #1


New D.I.C Head

*
Joined: 18 Sep, 2007
Posts: 2


My Contributions


Hi guys,

I don't know whether this is feasible or not. But here is my problem

I have a session variable which has database field names in a particular order and this variable is generated dynamically, I dont know what is in that variable and in what order. What I have to do is display my results in the order they are in the session variable. So for example if my session varialbe contains

session.sv = "Id,Name,Address,Phone,City,Location"

I am using this directly in my query as

select #session.sv# from details

And I want to display the records only in that particular order i.e Id, Name, Address, Phone, City and Location, this order is dynamic. So It can be City first, Address second etc...

Hope someone can tell me how to solve this issue.

Thanks in advance.
User is offlineProfile CardPM

Go to the top of the page


supersssweety
post 18 Sep, 2007 - 12:05 PM
Post #2


D.I.C Regular

Group Icon
Joined: 16 Mar, 2007
Posts: 292



Dream Kudos: 125
My Contributions


some code may help, are you trying to get it in the session variable in a certain order? Doesn't it need to be in a certain order to use in the query? How is the list of fields being put into the variable?

If you are just trying to see what is in the variable you can always use:
CODE
<cfdump var="#session.sv#">


post some code and we may be able to help you better
User is offlineProfile CardPM

Go to the top of the page

oldspice
post 18 Sep, 2007 - 12:20 PM
Post #3


New D.I.C Head

*
Joined: 18 Sep, 2007
Posts: 2


My Contributions


This is the query i am using and I am able to display the details from the database.

<cfquery name="Call_Det" datasource="collateral">
Select #replace(session.call_type,"*",",","All")#,Call_Id from Call_Info where Call_Type IN ('A', 'B')order by Call_Id
</cfquery>

However what i want is session.call_type will be in a particular order that means it contains call_id, call_type, call_location etc... and this order can change for every user for ex: it can change to call_type,call_id, call_location etc, since this order is dynamic, i wanted to know is there any way in coldfusion like loop the results and display them in that particular order.
User is offlineProfile CardPM

Go to the top of the page

sansclue
post 21 Nov, 2007 - 07:12 PM
Post #4


D.I.C Head

**
Joined: 21 Nov, 2007
Posts: 82



Thanked 4 times
My Contributions


Try adding an order by clause.

CODE

ORDER BY #replace(session.call_type,"*",",","All")#
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 9/8/08 09:09AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month