Unknow name of columns

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Unknow name of columns

    Hi there, I am new to CF, and I am interested, if it is possible to iterate
    through db results, if I don't know names of fields. I think example would be
    helpful:

    <cfquery name="myquery" datasource="mysqldb">
    select * from user
    </cfquery>

    later I want dynamicaly list all columns and all values without knowing their
    names:
    1. there is no problem with listing all names:
    <cfoutput>
    <table>
    <tr>
    <cfloop list="#myquery.ColumnList#" index="cn">
    <th>#cn#</th>
    </cfloop>
    </tr>
    </cfoutput>

    2. But how to go through all rows, and in each row through all columns, if I
    dont want use column names
    I am cusious about something like this
    <cfoutput query="myquery">
    <tr>
    <td>myquery.CurrentRow[1]</td> // - will display value
    of 1st column,
    <td>myquery.CurrentRow[2]</td> // - will display value
    of 2nd column,
    ....
    <td>myquery.CurrentRow[n]</td> // - will display value
    of nth column,
    </tr>
    </cfoutput>

    If you know how to do it, please let me know

    Algoro Guest

  2. Similar Questions and Discussions

    1. Unknow error
      We have implemented a plug-in using acrobat 7.0SDK (English version), whose functionality is to find the Links/Bookmarks present in a PDF and display...
    2. #40072 [NEW]: UTF8 file include output return unknow character.
      From: plasmapermanent at msn dot com Operating system: Windows XP SP2 PHP version: 5.2.0 PHP Bug Type: Output Control Bug...
    3. Unknow error (-108) on launch
      I am having troubles with Illustrator CS, I am unable to launch the programme, which haven't been a problem before now. (Sep 2003- may 2004) ...
    4. Unknow number of columns in repeater
      Hi. I have a datatable created at runtime that I want to display using a repeater control. The problem is that the number of columns of the...
    5. Pad strings/concatenate columns to simulate data columns in ASP select box with SQL Server 2K
      Dale, Cast all the data to fixed character data type in your select statement. For example: select cast(au_id as char(12)) +...
  3. #2

    Default Re: Unknow name of columns

    Go to the Usage section at
    [url]http://livedocs.macromedia.com/coldfusion/5.0/CFML_Reference/Tags78.htm#1102316[/url]
    are read up on CFQUERY. Note that in CF V5, there are three variables
    returned:

    query_name.recordCount - The number of records returned by the query.
    query_name.currentRow - The current row of the query being processed by
    cfoutput.
    query_name.columnList - A comma-delimited list of the query columns.



    jdeline Guest

  4. #3

    Default Re: Unknow name of columns

    Thanks, that's what I was looking for :)
    Algoro Guest

Posting Permissions

  • You may not post new threads
  • You may 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