Thank's for the responses. I couldn't quit get a structure to do what I
wanted.
Structures apparently will not sort. So I am trying it will an array.
I was working on generating automatic forms from a table query. I had
figured out
how to create the input type="text, checkbox, radio... But trying to create
a dropdown
I got stuck trying to do a loop over a loop. I got the country dropdown to
work.
<cfoutput query="qrytable">
<cfif #type_name# is "int">
<cfif #right(column_name, 2)# is "ID">
<cfif IsDefined("session.countries")>
<cfinclude template="/country.cfm">
</cfif>
</cfif>
</cfif>
</cfoutput>
Like so.
<CFQUERY NAME="qrycountry" DATASOURCE="datasource">
SELECT countryid, #client.l# as country
FROM countries
</CFQUERY>
<CFSET session.countries=ArrayNew(2)>
<CFLOOP QUERY="qrycountry">
<CFSET session.countries[CurrentRow][1]=qrycountry.CountryID[CurrentRow]>
<CFSET session.countries[CurrentRow][2]=qrycountry.Country[CurrentRow]>
</CFLOOP>
<CFSET Total_Records=qrycountry.RecordCount>
<select name="CountryID">
<option value="">Select Country</option>
<CFLOOP INDEX="Counter" FROM=1 TO="#Total_Records#">
<CFOUTPUT>
<option
value="#session.countries[Counter][1]#">#session.countries[Counter][2]#</opt
ion>
</CFOUTPUT>
</CFLOOP>
</select>
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Friday, December 15, 2000 7:53 AM
Subject: RE: Structures?????
> You're overwriting the same structure with each row. Try this:
>
> <cfquery name="thequery" datasource="datasource">
> select *
> from ads
> </cfquery>
>
> <Cfset stads = structnew()>
>
> <cfoutput query="thequery">
> <cfset structinsert(stads, thequery.adid, structnew())>
> <Cfset stads[thequery.adid].CDate = thequery.cdate>
> .. etc for other fields ...
> </cfoutput>
>
> <cfloop index="ii" list="#StructKeyList(stads)#" >
> <CFOUTPUT>
> AdID is #ii#
> CDate is #stads[ii].cdate#
> ... etc for other fields ...
>
> </CFOUTPUT>
> </cfloop>
>
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, December 14, 2000 3:55 PM
> To: CF-Talk
> Subject: Structures?????
>
>
> I'm getting frustrated with this. I want to build a structure from a query
> with multiple fields in each record
> in the structure. Then query the structure for a particular row. In other
> words use a structure like a DB
> table insert/edit/delete. I seem to be getting only one record in the
> structure. Anyone see what is wrong
> with this code??
>
>
> <cfquery name="thequery" datasource="datasource">
> select *
> from ads
> </cfquery>
> <cfscript>
> stads = StructNew();
> stads.adID="#thequery.adID#";
> stads.CDate="#thequery.CDate#";
> stads.Email="#thequery.Email#";
> stads.Phone="#thequery.Phone#";
> stads.City="#thequery.City#";
> stads.AdDesc="#thequery.AdDesc#";
> </cfscript>
> <cfloop query="thequery">
> <CFSCRIPT>
> stads=StructNew();
> StructInsert(stads, "adID", "#thequery.adID#");
> StructInsert(stads, "CDate", "#thequery.CDate#");
> StructInsert(stads, "email", "#thequery.email#");
> StructInsert(stads, "phone", "#thequery.phone#");
> StructInsert(stads, "City", "#thequery.City#");
> StructInsert(stads, "AdDesc", "#thequery.AdDesc#");
> </CFSCRIPT>
> </cfloop>
> <cfloop index="ii" list="#StructKeyList(stads, ',')#" delimiters=",">
> <CFOUTPUT>
> AdID is #StructFind(stads, "AdID")#
> CDate is #StructFind(stads, "CDate")#
> EMail is #StructFind(stads, "email")#
> Phone is #StructFind(stads, "phone")#
> City is #StructFind(stads, "City")#
> AdDesc is #StructFind(stads, "AdDesc")#
> </CFOUTPUT>
> </cfloop>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists