# Simple logic help (I hope)

Can someone tell me what I'm missing? I can't figure out why the last if (greater than 3) is not being entered. If I have 1 record it's fine, if I have 2 records it's fine, but once I have 3 or more records only the first if (greater than or equal to 1 and not equal to 2) displays. The last if (greater than 3) should show 2 times, but it never gets shown???

What am I missing?

``````%%[
SET @rows = LookupRows("Test_Audience","Subscriber_Key",subscriber_key)
SET @productCount = RowCount(@rows)

FOR @i = 1 TO @productCount DO

SET @row = Row(@rows, @i)
SET @PRODUCT = FIELD(@row, "PRODUCT")

IF @productCount >= 1 AND @productCount != 2 THEN
IF @i == 1 THEN
OUTPUT(ContentBlockbyKey("1_Product"))
ENDIF

ELSEIF @productCount == 2 THEN
OUTPUT(ContentBlockByKey("2_Products"))

ELSEIF @productCount >= 3 THEN
IF @i != 1 THEN
OUTPUT(ContentBlockByKey("Grid"))
ENDIF
ENDIF

NEXT @i
]%%
``````

Doh, it was dropping into the 1st if (greater than or equal to 1 and not equal to 2 each time). Stupid error. I changed it to:

``````%%[
SET @rows = LookupRows("Test_Audience","Subscriber_Key",subscriber_key)
SET @productCount = RowCount(@rows)

FOR @i = 1 TO @productCount DO

SET @row = Row(@rows, @i)
SET @PRODUCT = FIELD(@row, "PRODUCT")

IF @productCount >= 1 AND @i == 1 THEN
OUTPUT(ContentBlockbyKey("1_Product"))

ELSEIF @productCount == 2 THEN
OUTPUT(ContentBlockByKey("2_Products"))

ELSEIF @productCount >= 3 THEN
IF @i != 1 THEN
OUTPUT(ContentBlockByKey("Grid"))
ENDIF
ENDIF

NEXT @i
]%%
``````
• Ha ha. I was literally just about to post the above myself when I saw the 'new answers to this question' pop up. – Gortonington Sep 16 '16 at 18:06