MiniVend Akopia Services

[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date ][Minivend by thread ]

Re: how to do a simple counter loop?



******    message to minivend-users from Zachary Buckholz <zach@zak.doitnow.com>     ******

In SQL to return the count you would use somthing similiar to this

SELECT COUNT(field_name) FROM table_name WHERE something="something";

Do this before the loop, and if SUM=0 dont run the loop.

Replace words in lowercase above with the variables you want to use.

So to select the sum of items that are 14.95 or less use
SELECT COUNT(*) FROM cds WHERE price < 14.95;

if COUNT != 0 {
    Do your loop;
} else {
    Dont do your loop;
}

zack

>
>OK, I've just wasted a couple hours on this, I just don't get it...
>
>I need to run a counter while I go through a [sql] loop.  Basically, I want
>to do this:
>
>$i = 0
>[sql type=list query="select ..."]
>  stuff and nonsense...
>  ++$i
>[/sql]
>if $i == 0 then
>  there was nothing in the database
>
>I've tried various combos of [calc] (bad since the values show in the page)
>and [if explicit] (which seems to come out false or true invariably).
>
>Is there a standard idiom for running a counter and testing it in this
>circumstance?  I couldn't find it in the list archive.
>
>Thanks for any advice.
>-Alan
>
>=============
>Alan Sparks, IS Engineering Support
><asparks@nss.harris.com>
>Harris Communications, Camarillo CA                   (805) 389-2430
>
>-
>To unsubscribe from the list, DO NOT REPLY to this message.  Instead, send
>email with 'UNSUBSCRIBE minivend-users' in the body to
Majordomo@minivend.com.
>Archive of past messages: http://www.minivend.com/minivend/minivend-list
>

-
To unsubscribe from the list, DO NOT REPLY to this message.  Instead, send
email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
Archive of past messages: http://www.minivend.com/minivend/minivend-list


Search for: Match: Format: Sort by: