Solved

Saving an array to a string? ColdFusion.

Posted on 2014-01-13
2
291 Views
Last Modified: 2014-01-13
I am wondering if this is possible?
I would like to query a db:
Select color,car,age

FROM this table

color            car              age
blue           family             1
green         sport               2
red             van                 3



I want to output the results of the query as:
<cfset string="[blue,family,1] , [green,sport,2] , [red.van,3]">


 is this possible?

I have tried many ways, all are either outputting only a single row,  or trying to use ValueList()  i am returning :
 [blue,red,green] [family, sport,van] [1,2,3]...

Thanks!!!
0
Comment
Question by:izweig
2 Comments
 
LVL 39

Accepted Solution

by:
gdemaria earned 500 total points
ID: 39778321
Sure, you can format a string to look anyway you want it to look.

<cfset str = "">
<cfoutput query="myQuery">
   <cfset str = listAppend(str," [#myQuery.color#,#car#,#age#] ")>
</cfoutput>

<cfoutput>#str#</cfoutput>
0
 

Author Comment

by:izweig
ID: 39778338
Thank you, exactly what I was looking for! Soo easy when you know how!
0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question