Skip to main content
Known Participant
Mar 8, 2011 6:54 PM UTC
Question

Counting with CF

Hi all,

Is there anyway to use CF to count?  Sounds simple, but I'm querying a table with x amount of records and I need the output to be numbered 0-recordcount consecutively (first returned record would be 0, second returned record would be 1, etc.).  I thought about making a field in the table to input the numbers manually, or using an autonumber, but as records are added and deleted, these numbers will become inaccurate.  The output numbes really don't need to be related to the data in the table, I just need consecutive numbers starting with 0.

Thanks!

    This topic is closed to new replies. Start a new post to keep the conversation going.

    1 reply

    Inspiring
    Mar 8, 2011 7:11 PM UTC

    can I recommend you start with the docs for CFQUERY - http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7fae.html - and CFLOOP - http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-71a8.html - paying specific attention to RECORDCOUNT and CURRENTROW.

    --

    Adam

    Translate