• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 158
  • Last Modified:

Increment by 1, starting at 2

I need to increment numbers starting at 2 and increasing by one after each loop,

So

2
3
4
5
6
0
jeffmace
Asked:
jeffmace
  • 2
1 Solution
 
SidFishesCommented:
are you looping over a query?

<cfset vInt = 2>

<cfloop name ="looper" datasource="mydata">
#vInt#
<Cfset vInt = vInt+1>
</cfloop>
0
 
SidFishesCommented:
oops... too early


<cfquery name="looper" datasource="mydata">
select * from mytable
</cfquery>
<cfset vInt = 2>
<cfloop query ="looper">
#vInt#
<Cfset vInt = vInt+1>
</cfloop>
0
 
mkishlineCommented:
We can give you a better answer if we know the context for your looping.

<cfset lastnumber = 10 />
<cfoutput>
  <cfloop index="i" from="2" to="#lastnumber#">
    #i#<br />
  </cfloop>
0
 
jeffmaceAuthor Commented:
Nope, that did the trick.. Perfect.. Thank you both
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now