Hi I have a farcry project on the go which basically involves the client populating a database with lots of information that relates to various different products. The client is able to create a new "field" into the database and assign a value to that field. So as a whole, there will be an ever increasing number fields in the database (15+), but perhaps within each entry, only some of those fields will have data in them that is relevant to the entry
ie. id product type price status date folder description type size 1 blah 100 enabled blah 2 blah new 50 2010 test vertical 3 blah box 4 I know I can loop through the database to get all the field names (remember, these will change dynamically as the client adds new fields so I dont want to be having to manually update code at all) <cfquery datasource="SQLdbName" name="getFields"> select column_name,* from information_schema.columns where table_name = 'myTableName' order by ordinal_position </cfquery> I can build up an array of those fields that are not empty: <cfif getFields.recordcount gt 0> <cfset fieldArray = #ArrayAppend(fieldArray,column_name)# > </cfif> then loop through the array in another query to try and get the field values for a particular id: <cfloop from="1" to="#ArrayLen(fieldArray)#" index="r"> <cfquery datasource="SQLdbName" name="getValues"> SELECT #fieldArr[r]# FROM myTableName WHERE id = '3' </cfquery> </cfloop> but this dosnt seem to work and part of me thinks Im going down a long winded route when perhaps the actual code to achieve what Im after is much more condensed. Im not too clued up on SQL queries so any help much appreciated! Cheers B -- You received this message cos you are subscribed to "farcry-dev" Google group. To post, email: [email protected] To unsubscribe, email: [email protected] For more options: http://groups.google.com/group/farcry-dev -------------------------------- Follow us on Twitter: http://twitter.com/farcry
