?
Solved

query_name.columnList - display vertically?

Posted on 2011-03-16
5
Medium Priority
?
445 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 2000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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 …
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

864 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