Derek,

see if the following code makes sense for what you're trying to do:

<cfquery name="getusers" datasource="#datasource#">
        select *
        from users 
        order by fullname asc
</cfquery>

<cfset arrUsers = arraynew(1)>

<cfloop query="getusers">
        <cfset x = getusers.currentrow>
        <cfset arrUsers[x] = structnew()>
        <cfset arrUsers[x].userid = "#userid#">
        <cfset arrUsers[x].password = "#password#">
        <cfset arrUsers[x].fullname = "#fullname#">
        <cfset arrUsers[x].company_code = "#company_code#">
        <cfset arrUsers[x].address1 = "#address1#">
        <cfset arrUsers[x].address2 = "#address2#">
        <cfset arrUsers[x].city = "#city#">
        <cfset arrUsers[x].state = "#state#">
        <cfset arrUsers[x].zip = "#zip#">
        <cfset arrUsers[x].phone = "#phone#">
        <cfset arrUsers[x].fax = "#fax#">
        <cfset arrUsers[x].email = "#email#">
        <cfset arrUsers[x].department = "#department#">
</cfloop>

to output, do the following:

<cfloop from="1" to="#arraylen(arrUsers)#" index="x">
        <cfoutput>
                #x# - #arrUsers[x].userid#<br>
                #x# - #arrUsers[x].password#<br>
                #x# - #arrUsers[x].fullname#<br>
                #x# - #arrUsers[x].company_code#<br>
                #x# - #arrUsers[x].address1#<br>
                #x# - #arrUsers[x].address2#<br>
                #x# - #arrUsers[x].city#<br>
                #x# - #arrUsers[x].state#<br>
                #x# - #arrUsers[x].zip#<br>
                #x# - #arrUsers[x].phone#<br>
                #x# - #arrUsers[x].fax#<br>
                #x# - #arrUsers[x].email#<br>
                #x# - #arrUsers[x].department#<br><br>
        </cfoutput>     
</cfloop>

HTH

Mark Stewart
Programmer/Analyst
Communication Concepts
215.672.6900 x1332

>>> [EMAIL PROTECTED] 03/28/01 05:35PM >>>
I was wondering how people have created structures from queries.  I have a few queries 
that I run that I want to move into one array of structures so that I can sort/display 
them at once instead of three different sort/displays with each query.  This is what I 
have done so far:
    
    <cfset aCategory = ArrayNew(1)>
    
    <cfoutput query="get_Categories">
    <cfset structCat = StructNew()>
    <cfset RESULT = InsertStruct(structCat, "CAT_ID", #cat_id#)>
    <cfset RESULT = InsertStruct(structCat, "CAT_ID", #cat_title#)>
    <cfset RESULT = ArrayAppend(aCategory, structCat)>
    </cfoutput>

(I cut out some of the error catching, etc that I do with RESULT.)

The problem I am having is that when I call the ArrayAppend it does append but I end 
up with only one element in the array even though there are more in the resultset.  
Does this have to do with the fact that in my cfoutput I use the same structure name?  
Is the structure being copied into the array by value or by reference?  And, is that 
what is messing things up?

I hope that my question/problem is clear!

BTW, if anybody has any better ideas for merging 3 or more queries into one resultset 
I would love to hear them as I might just be going about this whole thing wrong.

TIA, 

Derek Hamilton
Systems Developer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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

Reply via email to