Professional Web Applications Themes

Creating a dynamic table from a query - Macromedia ColdFusion

Hi cfml-cracks :) For me as a php developper, coldfusion is quite a confusion... I'd like to display a query-result as a table, it's very easy if you know what kind of columns you'll want to display, but as I want the users to be able to chose the columns I'm stuck. Does anyone of you has an idea or a piece of code which deals with this problem! I'd appreciate any kind of help! Thank you very much Markus...

Sponsored Links
  1. #1

    Default Creating a dynamic table from a query

    Hi cfml-cracks :)

    For me as a php developper, coldfusion is quite a confusion... I'd like to
    display a query-result as a table, it's very easy if you know what kind of
    columns you'll want to display, but as I want the users to be able to chose the
    columns I'm stuck.

    Does anyone of you has an idea or a piece of code which deals with this
    problem!

    I'd appreciate any kind of help!

    Thank you very much
    Markus

    Sponsored Links
    marksta80 Guest

  2. #2

    Default Re: Creating a dynamic table from a query

    Read about the columnList property of CFQUERY.

    JR

    jonwrob Guest

  3. #3

    Default Re: Creating a dynamic table from a query

    Thank you for your quick reply, thank to which I've found some interessting
    things about the cfquery, but unfortunately I couldn't solve my problem, to
    display a dynamic amount of cells

    <cfscript>
    fieldArray = listToArray(searchRes.records.columnList);
    </cfscript>
    <cfoutput query="searchRes.records">
    <cfscript>
    for (i=0; i lt ArrayLen(fieldArray); i = i+1) {
    WriteOutput('<td>' & searchRes.records.fieldArray &'</td>');
    }
    </cfscript>
    </cfoutput>

    Of course this can't work because the searchRes.records object doesn't have a
    property called fieldArray, actually I would need some kind of "eval" function
    to make this work.

    I'd be very happy if any body out there could give me another hint.

    Thanks
    Markus

    marksta80 Guest

  4. #4

    Default Re: Creating a dynamic table from a query

    Access the query column/row values like a structure:
    queryName[columnName][rowNumber]



    <table>
    <cfoutput query="yourQuery">
    <tr>
    <cfloop from="1" to="#ArrayLen(fieldArray)#" index="i">
    <td>#yourQuery[fieldArray[i]][currentRow]#</td>
    </cfloop>
    </tr>
    </cfoutput>
    </table>

    mxstu Guest

  5. #5

    Default Re: Creating a dynamic table from a query

    Thanks! A correct solution at this time of the day on a sunday. Wow!
    marksta80 Guest

Similar Threads

  1. Creating data query from mySQL stored query!?
    By johnegbert in forum Coldfusion Database Access
    Replies: 2
    Last Post: August 5th, 09:28 PM
  2. creating dynamic table in oracle
    By kishoreb in forum Coldfusion Database Access
    Replies: 1
    Last Post: May 10th, 06:12 PM
  3. creating a dynamic table with subcategories
    By davellaman in forum Coldfusion - Advanced Techniques
    Replies: 0
    Last Post: May 11th, 06:24 PM
  4. Replies: 5
    Last Post: July 17th, 06:59 PM
  5. How to create a table with dynamic table name
    By cathy wang in forum Informix
    Replies: 3
    Last Post: July 17th, 12:46 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139