Solved

query_name.columnList - display vertically?

Posted on 2011-03-16
5
429 Views
Last Modified: 2012-05-11
hi all,

is it possible to force a br tag after each comma in a query_name.columnList?

i can give more info if needed

z

0
Comment
Question by:bede123
  • 3
  • 2
5 Comments
 
LVL 39

Accepted Solution

by:
gdemaria earned 500 total points
Comment Utility

<cfset newList = listChangeDelims(valueList(query_name.columnList),",<br>")>

Now newList should contains  one,<br>two,<br>three,<br>four

Of course you could also just loop through the values add format as you wish

<cfloop index="xx" list="#valueList(query_name.columnList)#">
   #xx#<br>
</cfloop>
0
 
LVL 1

Author Comment

by:bede123
Comment Utility
many thanks. i can get both to work but it seems there might be an issue with the way i'm querying for the column names because they seem to be repeated twice:

SELECT *
FROM ProdFields
LIMIT 1

results in:

AUTOID,
PRODNAME,
AUTOID,
PRODNAME

you see how this table only has two colums but its repeated twice.

before using the SELECT *

i was using:

SHOW COLUMNS

Butr that gave me:

EXTRA
FIELD
TYPE
NULL
KEY
DEFAULT
EXTRA

which is not what i'm after as its not actually the column names.....
0
 
LVL 39

Expert Comment

by:gdemaria
Comment Utility
If you are after the column names, you should be able to grab them after a CFQUERY.  It doesn't matter how many records are returned 0, 1, or many

<cfquery name="myQuery" datasource="...">
  SELECT * FROM ProdFields
</cfquery>

<cfoutput>#myQuery.columList#</cfoutput>

If you're doing much more than that, perhaps there is a problem with the specific code; if so, please post the code..  Thanks
0
 
LVL 1

Author Comment

by:bede123
Comment Utility
Yes that exactly what i was doing BUT from looking at the cfdump info i realised that by doing:

SELECT *

i was querying the db for everything in the table, and the plan is for this table to be big!

so i added:

LIMIT 1

but apart from that my code is the same as yours. even if i take the LIMIT 1 out it still returns the whole thing twice:

AUTOID
PRODNAME
AUTOID
PRODNAME




however i'm going to close the question and award the points because the original question has been answered. i will post back with a new question after i have done some googling.

many thanks again

gdemaria.


z
0
 
LVL 39

Expert Comment

by:gdemaria
Comment Utility
> i was querying the db for everything in the table, and the plan is for this table to be big!

you can also not return any rows, so this will work as well..

 SELECT * FROM TABLE WHERE 1 = 2

that will not return any rows, but will give you your column names

In your new question, please post some code, the problem is probably specific to your code as you have the right approach

0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now