Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

query_name.columnList - display vertically?

Posted on 2011-03-16
5
438 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
ID: 35149715

<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
ID: 35149858
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
ID: 35149915
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
ID: 35149969
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
ID: 35150002
> 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

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 …
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

840 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