#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2004
    Posts
    1
    Rep Power
    0

    Retreiving fields from Access DB, Cold Fusion


    I am retreiving all fields from a certain table in my Access DB and want to output the data in those fields on my page. The table is specified by the URL parameter, so I need the output to correspond with the correct table. So i cant simply just <cfoutput>#fieldname#</cfoutput> because the field names are different for each table.

    Basically, is there a way to output all the info in a table without specifying the field names? Like a <cfoutput>#ALL#</cfoutput> or something?????

    My code:
    <cfquery datasource="XX" name="getRecords">
    <cfset table = URL.record>
    SELECT * FROM #table#

    </cfquery>
    <cfloop query="getRecords">
    <cfoutput> </cfoutput>
    </cfloop>

    Thanks for your help, hope you understand what I'm saying!
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,143
    Rep Power
    4274
    #queryname.ColumnList# will give you a comma-delimited list of the query columns

    you can loop over those with a cfloop inside the main cfoutput
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
  4. #3
  5. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,264
    Rep Power
    968
    I'd be throwing up a huge red flag on this approach, unless you truly have no security concerns. For example, if you have a table with user names and passwords, it would be trivial for a malicious user to alter the URL parameter and end up with a full list of all your users and passwords. Be careful.

IMN logo majestic logo threadwatch logo seochat tools logo