Hi all,

Thank you for the feedback, you really got me thinking. To put it very
simply, in order to take the db row values and convert them to column names
with values, I created a new structure.  A Structure allowed me to create
multiple virtual columns. A structures column labels are called keys, and
the "one" row value is the structure value.

Proposed benefits... If you have a side side nav that you don't want to hard
code, but keep in a db you can type the variables without looping or query
or evaluating.

// The following will be set in application.cfm with a IsDefined checker.

<CFSET Server.MyStructureSideNav = "">
<CFSET Server.MyStructureSideNav = StructNew()>

<CFQUERY NAME="MyQuery" DATASOURCE="xyz" DBTYPE="ODBC">
        SELECT *
        FROM SideNavTable
</CFQUERY>

 <CFOUTPUT QUERY="MyQuery">
      <CFSET rc=StructInsert(Server.MyStructureSideNave, "#MyQuery.Var#",
"#MyQuery.VarString#")>
 </CFOUTPUT>

// Now the display page is simplified.
<CFOUTPUT>
    #MyStructureSideNav.Home#
    #MyStructureSideNav.ContactUS#

    // The beauty is now I can simply use a local query variable
    #SomeOtherQuery.SpecialDeal#
</CFOUTPUT>

Thanks again, and hope it helps others. Any points of clarification, esp
since I'm just starting to grasp the structure concept, are encouraged.

Rick


----- Original Message -----
From: "Kevin Marshall" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, July 10, 2000 8:11 AM
Subject: Re: Need to take several row query and make into one row.


> Rick,
>
> You may want to take a look at a custom tag called CF_QueryToStruct.
> Basically it will take a query like yours and convert it to a struct that
> would look like this:
> MyQuery.MyVar.MyValue
>
> I've used this tag with great success in a situation something like yours.
>
> Find the tag at:
>
http://devex.allaire.com/developer/gallery/info.cfm?ID=CA34740D-2830-11D4-AA
> 9700508B94F380&method=Full
> (yep, the url probably wrapped - if you want, just search in the
Developers
> Exchange for "QuerytoStruct")
>
> Kevin
>
>
> At 05:16 PM 7/9/00 -0700, you wrote:
> >Hello,
> >
> >The "why" for the following is an email unto itself, so if possible any
> >ideas on "how" would be greatly appreciate.
> >
> >The cfquery name="MyQuery" is selecting from the following db table:
> >
> >MyKey    |    MyVar            |     MyValue
> >---------------------------------------------
> >0001        |    ClientName      |    Rick
> >0002        |    SeminarsFor    |    aerospace
> >0003        |    RAMPrice        |    stable
> >
> >Now I need to write (without looping or cfifing or cfswitching) or
(changing
> >the the table itself) and (caching of some sort is desired):
> >
> >The name of your seminar is: #MyQuery.SeminarsFor#
> >The state of CA is: #SomeOtherQuery.HighTaxes#
> >
> >The only way I've been able to do it so far is to rebuild the above table
> >into:
> >ClientName |    SeminarsFor    |    RAMPrice
> >--------------------------------------------
> >Rick            |    aeospace        |     stable
> >
> >But this constant table manipulation isn't practical.
> >
> >Is the answer in sql? structures? arrays? or ?
> >
> >TIA,
> >
> >Rick
>
> --------------------------
> Kevin Marshall
> Web Application Developer
> eCalton.com, Inc.
> Vero Beach, FL
> www.ecalton.com
> [EMAIL PROTECTED]
> 561.569.4500
>
> --------------------------------------------------------------------------
----
> Archives: http://www.mail-archive.com/[email protected]/
> To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.


__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to