I have a table of the top 3 food brands available at each location.


Location | Brand      
New York | Coffee Shop
New York | Bagel Shop
New York | Deli 
Houston  | Steakhouse
Houston  | Bagel Shop
Houston  | Smoothies

I generated a rowset of available Brands at a specific Location (matching that of the current user viewing the content).


Joe is viewing the email and he is located in Houston. I want him to see the top 3 food shops in Houston. I've been able to get this to display with a loop, however, what I have been stumped on is the styling piece.

The tricky part is each block he sees will have an image icon detonating the rank of that shop. Since I know it will always be 3 brands displayed, is there a way I can call out for "Row 1" use image icon number 1, for "Row 2", use image icon number 2, for "Row 3", use image icon number 3.

enter image description here

After each brand is listed there is also a different Call to Action link and a separator, but by the third brand, I do not want there to be a separator under it.

I've only been able to create a loop that displays the different brands and images, but I can't figure out how to change the number icon according to it's rank, and I can't figure out how to change the CTAs according to it's rank either.

  • 1
    Can you post what you've tried so far -- like the some abbreviated code? – Adam Spriggs Aug 17 '19 at 0:01
  • Without any of your code, this looks like a test question. Hope that's not the case. – Adam Spriggs Aug 19 '19 at 13:59

You can just output the separator as long as you're not on the final product in your loop:


var @i, @max
set @max = 3


%%[ for @i = 1 to @max do ]%%

    %%[ if @i == 1 then ]%%

        <!-- output product 1 here -->

    %%[ elseif @i == 2 then ]%%

        <!-- output product 2 here -->

    %%[ elseif @i == 3 then ]%%

        <!-- output product 3 here -->

    %%[ else ]%%

        <!-- output product default here -->

    %%[ endif ]%%

    %%[ /* if it isn't the last product */ ]%%

    %%[ if @i < @max then ]%%

        <!-- output separator --> 

    %%[ endif ]%%

%%[ next @i ]%%
| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.