loop
[loop] is designed to repeat html or WebDNA code. The [loop] context requires two parameters: start and end. Looping occurs between, and including, the start and end value; advancing by 1 each time. An "advance" value may optionally tell the loop context to advance by a specified amount, other than 1, by using the advance parameter.
Parameters
Parameter | Description |
---|---|
start | The starting index value to begin looping. This value is required and may be positive or negative. |
end | The ending index value when looping. This value is required and may be positive or negative. |
advance | (Optional) The amount to advance by when looping. This parameter is optional and may be positive or negative, the default value is 1. |
The following tags are available inside a [loop] context:
Tag | Description |
---|---|
[index] | Displays the current index number between or including start and end. |
[break] | If the [loop] context sees the [break] tag while executing a loop, it will stop looping, once it finishes the current loop. Thus the [break] tag should only appear in a [showif] statement that is evaluated at the end (bottom) of the loop. |
Example WebDNA code:
[loop start=1&end=4&advance=1]
[append db=some.db]...[/append]Record [index] added.<br>
[/loop]
The result would be:
Record 1 added.
Record 2 added.
Record 3 added.