Do you mind to include some comments so I know what the new code does
exactly. I knew there had to be a more dynamic way to do this and it
appears to be great but I'm trying to learn new techniques as I go
here.

Thank you!

On Thu, 7 Oct 2004 12:14:17 -0700, Charlie Griefer
<[EMAIL PROTECTED]> wrote:
> the following would reduce your lines of code by more than half ...
> (assuming I'm not overlooking something...which may be a rather large
> assumption) :)
>
> <cfquery name="rdDetails" datasource="#dsn#">
> SELECT *
> FROM tblProducts
> WHERE
> ProdID = <cfqueryparam value="#URL.prodID#" cfsqltype="cf_sql_integer">
> </cfquery>
>
> <cfif (rdDetails.typeID GTE 1) AND (rdDetails.typeID LTE 3)>
> <cfquery name="rsType" datasource="#dsn#">
> SELECT *
> FROM tblTypes
> WHERE
> typeID = <cfqueryparam value="#typeID#" cfsqltype="cf_sql_integer">
> </cfquery>
> <cfoutput query="rsType">
> #trim(typeDesc)#
> </cfoutput>
> <cfelse>
> <cfinclude template="defaultdetails.cfm" />
> </cfif>
>
>
> On Thu, 7 Oct 2004 14:02:49 -0500, Donna French <[EMAIL PROTECTED]> wrote:
> > Okay, here's what I've come up with so far. Let me know any comments -
> > good, bad or indifferent.
> >
> > <cfquery name="rsDetails" datasource="#dsn#">
> >   SELECT *
> >   FROM tblProducts
> >   WHERE ProdID = #URL.ProdID#
> > </cfquery>
> >
> > <cfoutput query="rsDetails" datasource="#dsn#">
> > <cfswitch _expression_="#Trim(TypeID)#">
> >   <cfcase value="1">
> >     <!--- Display layout for TypeID 1 --->
> >         <cfquery name="rsType1" datasource="#dsn#">
> >           SELECT *
> >           FROM tblTypes
> >           WHERE TypeID = 1
> >         </cfquery>
> >         <cfoutput query="rsType1">
> >           #Trim(TypeDesc)#
> >         </cfoutput>
> >   </cfcase>
> >   <cfcase value="2">
> >     <!--- Display layout for TypeID 2 --->
> >     <cfquery name="rsType2" datasource="#dsn#">
> >       SELECT *
> >       FROM tblTypes
> >       WHERE TypeID = 2
> >     </cfquery>
> >     <cfoutput query="rsType2">
> >       #Trim(TypeDesc)#
> >     </cfoutput>
> >   </cfcase>
> >   <cfcase value="3">
> >     <!--- Display layout for TypeID 3 --->
> >     <cfquery name="rsType3" datasource="#dsn#">
> >       SELECT *
> >       FROM tblTypes
> >       WHERE TypeID = 3
> >     </cfquery>
> >     <cfoutput query="rsType3">
> >       #Trim(TypeDesc)#
> >     </cfoutput>
> >   </cfcase>
> >   <cfdefaultcase>
> >         <!--- Display default layout --->
> >         <cfinclude template="defaultdetails.cfm">
> >   </cfdefaultcase>
> > </cfswitch>
> > </cfoutput>
> >
> > TIA,
> > Donna
> >
> > On Thu, 7 Oct 2004 13:38:38 -0500, Donna French <[EMAIL PROTECTED]>
> wrote:
> > > Okay, I did a little reading at lunch and understand a little more
> > > about CFIF vs. CFSWITCH in the CFMX Web App Kit book. No more than I
> > > knew at first I couldn't really figure out why both were available,
> > > but now I see more clearly and have decided to use CFSWITCH.
> > >
> > > Thank you to all that took the time to post and try to help!
> > >
> > > Peace,
> > > Donna
> > >
> > >
> > >
> > >
> > > On Thu, 7 Oct 2004 12:21:53 -0500, Donna French <[EMAIL PROTECTED]>
> wrote:
> > > > So far I can't really see the difference but here's a little more
> > > > detailed info so that maybe someone can tell me what might be best for
> > > > my specific scenario.
> > > >
> > > > We have different types of products, and each needs to be displayed
> > > > differently. So here's what I came up with as far as db structure at
> > > > this point.
> > > >
> > > > tblTypes
> > > > ------------
> > > > TypeID
> > > > TypeName
> > > > TypeDesc (Actual CFML to display product details)
> > > >
> > > > Product detail page:
> > > >
> > > > <CFIF TypeID = 0>
> > > > Use Default Layout
> > > > <CFELSEIF TypeID = 1>
> > > > Use Layout 1
> > > > <CFELSEIF TypeID = 2>
> > > > Use Layout 2
> > > > </CFIF>
> > > >
> > > > HTH - thanks for your help,
> > > >
> > > > Donna
> > > >
> > > > On Thu, 7 Oct 2004 10:04:52 -0700, Ian Skinner
> > > >
> > > >
> > > > <[EMAIL PROTECTED]> wrote:
> > > > > Donna
> > > > >
> > > > > �������� I think that's enough for you to understand what I mean.
> The #TypeID#
>
>
> > > > > > and #Layout# will come from a table that could have an unlimited
> > > > > > number of results, so I'd like to use the option best for dynamic
> > > > > > results.
> > > > >
> > > > > For the example you provided, both your cfif/cfifelse/cfelse block
> and a
> > > > > cfswitch/cfcase block would for all practical purposes be the same.
> > > > >
> > > > > But they would both fall short on a requirement I read in your above
> quote.
> > > > > They both would require one to know what all the possible values of
> > > > > TypeID/Layout could be ahead of time, but you indicated that there
> could be
> > > > > an unlimited number of results.  It would not really be possible to
> have an
> > > > > "unlimited" number of branches in either at cfif/cfifelse/cfelse or
> a
> > > > > cfswitch/cfcase structure.
> > > > >
> > > > > Without knowing more about your application's requirements and logic
> I can't
> > > > > give much advice.  But I suspect I would probably build something
> that
> > > > > simply called a version of "layout" based on the value of "typeID,"
> possible
> > > > > a structure {layout[typeID]} or something like that.
> > > > >
> > > > > --------------
> > > > > Ian Skinner
> > > > > Web Programmer
> > > > > BloodSource
> > > > > www.BloodSource.org
> > > > > Sacramento, CA
> > > > >
> > > > > "C code. C code run. Run code run. Please!"
> > > > > - Cynthia Dunning
> > > > >
> > > > > Confidentiality Notice:  This message including any
> > > > > attachments is for the sole use of the intended
> > > > > recipient(s) and may contain confidential and privileged
> > > > > information. Any unauthorized review, use, disclosure or
> > > > > distribution is prohibited. If you are not the
> > > > > intended recipient, please contact the sender and
> > > > > delete any copies of this message.________________________________
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to