Jeff
Try this - the variable "stads" needs to be an array, then each element in
that array
is set up as a structure. I believe the way you had it set up, the structure
was simply
overwriting itself for each iteration of the loop.
Obviously, I can't test this against your data, but this should work fine.
Rick
<cfquery name="thequery" datasource="datasource">
select *
from ads
</cfquery>
<CFSCRIPT>
stads=ArrayNew(1);
</CFSCRIPT>
<cfloop query="thequery">
<CFSCRIPT>
stads[#thequery.currentrow#]=StructNew();
StructInsert(stads[#thequery.currentrow#], "adID", "#thequery.adID#");
StructInsert(stads[#thequery.currentrow#], "CDate",
"#thequery.CDate#");
StructInsert(stads[#thequery.currentrow#], "email",
"#thequery.email#");
StructInsert(stads[#thequery.currentrow#], "phone",
"#thequery.phone#");
StructInsert(stads[#thequery.currentrow#], "City", "#thequery.City#");
StructInsert(stads[#thequery.currentrow#], "AdDesc", "#thequery.AdDesc#");
</CFSCRIPT>
</cfloop>
<cfoutput>
<cfloop index="i" from="1" to="#ArrayLen(stads)#">
#stads[i].AdID#<br>
#stads[i].CDate#<br>
#stads[i].email#<br>
#stads[i].phone#<br>
#stads[i].City#<br>
#stads[i].AdDesc#<br>
</cfloop>
</cfoutput>
-----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