(assuming your cart is an array of structures...)

<cfscript>
     var green       = 0;
     var not_green = 0;

     for (i=1; i LTE arrayLen(session.cartArrayName); i=i+1) {
          if (cartArrayName[i].Type is "green") {
               green = green + 1;
          } else {
                not_green = not_green + 1;
          }
     }
</cfscript>

On Thu, 26 Aug 2004 11:33:51 +0200, mc <[EMAIL PROTECTED]> wrote:
> I've got a shopping cart that is in an array (stored in a session). It looks
> like this:
>
> Item      Quantity     Type
> -----------------------------
> pepper     2           green
> avocado    1           green
> carrot     3           not green
> eggplant   1           not green
> celery     5           green
>
> What I need to do is figure out the total quantity of "not green" items and
> "green" items (in this case, 8 "green" items; 4 "not green" items).
>
> I'm not at all sure how to go about this, as I've always used databases and
> queries to do this sort of thing. Am I out of luck or is there some way to
> query the data in an array that isn't too horribly complicated?
>
> P.S. Please forgive me if this issue has already been dealt with here. I
> just took a two year break from CF and my brain is a bit out of shape...
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to