• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to Output All Rows but Dynamically Limit Columns?

New Here ,
Oct 05, 2007 Oct 05, 2007

Copy link to clipboard

Copied

Hi Everyone:

I am pretty new to Coldfusion and I'm stuck on how to do a specific kind of search in Coldfusion.

Here is the basics:

1. I am working with one table (called COURSES).
2. Within that table are several columns. Here is what my boss wants.
-He wants all of the courses to always be output.
-He wants ONLY the columns that are checkmarked (using checkmark boxes) to be outputed.

3. I was thinking that I need to use
<cfif> statements to produce some form of dynamic sql that would output all of the courses, but only the columns the enduser wants to view.

I'm not sure how to do that (I've tried for a day now).

Here are the columns in the table that are important:

<cfquery name="rsCOURSES" datasource="SCHEDULING_TRACKER">
SELECT COURSE_NAME, MT_ID, DOCUMENTATION_DATE, PRESENTATION_FILES_DATE, JOB_AIDS_DATE
FROM dbo.COURSES
ORDER BY COURSE_NAME ASC
</cfquery>

One of the issues (is it an issue?) is that 3 of the above are date columns. The check boxes are just to determine whether those columns should be displayed.
I am exporting to an excel file (which I think I figured out ok).

Thanks for any help.
Matthew
TOPICS
Advanced techniques

Views

252

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 05, 2007 Oct 05, 2007

Copy link to clipboard

Copied

On your form, give all the checkboxes the same name, but different values. When you submit your form, you get a list of values. Use that list in the select clause of your query.

You'll need to do something to cope with no boxes being selected of course.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 05, 2007 Oct 05, 2007

Copy link to clipboard

Copied

LATEST
Thanks for the help Dan.

I tried but so far was unsuccessful. I'm going to do some futher reading on Coldfusion/SQL this weekend and try your advice Monday. I'll let you know Monday how I fair. Have a good weekend.
Matthew

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation