Hi I have some ampscript that pulls data in from the data extension into the email template. When I preview it the first section shows up 3 times as a duplicate but the other two sections show fine. I'm trying to stop the first section from showing up 3 times. I checked for similar questions but not having much luck. Maybe I need a second pair of eyes to see what I missed.
%%[
set @rows = LookupOrderedRows("Consult_Notifications_Daily_Digest",3,"date desc","EmailAddress",emailaddr)
]%%
%%[
set @rowCount = rowcount(@rows)
if @rowcount > 1 then
for @i = 1 to @rowCount do
set @row = row(@rows,@i)
set @mentionNotificationType = field(@row,"NotificationType_Mention_1")
set @mentionNotificationType = field(@row,"NotificationType_Mention_2")
set @mentionNotificationType = field(@row,"NotificationType_Mention_3")
set @mentionPostName = field(@row,"PostName_4")
set @mentionPostName5 = field(@row,"PostName_5")
set @mentionPostName6 = field(@row,"PostName_6")
set @mentionTargetURL = field(@row,"targeturl_4")
set @mentionTargetURL5 = field(@row,"targeturl_5")
set @mentionTargetURL6 = field(@row,"targeturl_6")
set @mentionRecipientName = field(@row,"RecipientName")
set @mentionMentionedUser = field(@row,"MENTIONEDUSER")
set @mentionActorName = field(@row,"ActorNameDeg")
set @mentionUser = field(@row,"User_1")
set @mentionPostTitle = field(@row,"PostTitle_4")
set @mentionUserAccountUrl = field(@row,"UserAccountUrl")
set @mentionActorAccountUrl = field(@row,"ActorAccountUrl_4")
set @mentionActorAccountUrl5 = field(@row,"ActorAccountUrl_5")
set @mentionActorAccountUrl6 = field(@row,"ActorAccountUrl_6")
set @mentionThreadUrl = field(@row,"ThreadUrl_4")
set @mentionThreadUrl5 = field(@row,"ThreadUrl_5")
set @mentionThreadUrl6 = field(@row,"ThreadUrl_6")
set @mentionDate = field(@row,"Date")
set @mentionPostBody = field(@row,"PostBody_4")
set @mentionPostBody5 = field(@row,"PostBody_5")
set @mentionPostBody6 = field(@row,"PostBody_6")
if @mentionNotificationType == 'User' then
]%%
-->
<tr>
<td style="padding: 7px 0 0 0;">
<table width="560" cellpadding="0" cellspacing="0" borde="0" class="container">
<tr>
<td align="center" valign="middle" style="padding:2px 2px 3px 1px; box-shadow: 2px 2px 2px 0 rgba(0, 0, 0, 0.09);" bgcolor="#dfdfdf">
<table width="558" class="container" border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff">
<tr>
<td style="padding:20px 20px 20px 20px; font-size: 14px;" align="left">
<table width="508" class="container" border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff">
<tr>
<td width="508" style="padding: 0 0px 0 0;" class="container" colspan="1" valign="top">
<table width="508" class="container" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left" style="font-size: 18px;font-family: 'Roboto Condensed','Helvetica',Arial,sans-serif; font-weight: none; padding:0 0 10px 0; line-height: normal;">
<a href="%%=redirectTo(@mentionTargetURL)=%%" style="font-size: 18px;color: #000000;text-decoration:none;font-family: 'Roboto Condensed','Helvetica',Arial,sans-serif; font-weight: none; padding:0 0 10px 0; line-height: normal;">%%=v(@mentionPostName)=%%</a>
</td>
</tr>
%%[if not empty(@mentionPostBody) then]%%
<tr>
<td align="left" style="font-size: 14px;font-family: 'Roboto Condensed','Helvetica',Arial,sans-serif; font-weight: none; padding:0 0 10px 0; line-height: normal; color: #606060;">
%%=v(@mentionPostBody)=%% .. <a href="%%=redirectTo(@followedReplyTargetURL)=%%" target="_blank" style="font-size: 14px;font-family: 'Proxima Nova','Helvetica',Arial,sans-serif; font-weight: normal; text-decoration: none; color: #007cb0;">read more</a>
</td>
</tr>
%%[endif]%%
<tr>
<td align="left" style="padding: 0px 0 0px 0; font-size: 14px;font-family: 'Proxima Nova','Helvetica',Arial,sans-serif; color: #3a3b3c;">
<a href="%%=redirectTo(@mentionActorAccountUrl)=%%" target="_blank" style="font-size: 14px;font-family: 'Proxima Nova','Helvetica',Arial,sans-serif; font-weight: normal; text-decoration: none; color: #007cb0;">%%=v(@mentionRecipientName)=%%</a> responded to your post on %%=v(@mentionDate)=%%.
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<!-- End script
%%[
else
endif next @i endif
]%%
-->
<tr>
<td style="padding: 7px 0 0 0;">
<table width="560" cellpadding="0" cellspacing="0" borde="0" class="container">
<tr>
<td align="center" valign="middle" style="padding:2px 2px 3px 1px; box-shadow: 2px 2px 2px 0 rgba(0, 0, 0, 0.09);" bgcolor="#dfdfdf">
<table width="558" class="container" border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff">
<tr>
<td style="padding:20px 20px 20px 20px; font-size: 14px;" align="left">
<table width="508" class="container" border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff">
<tr>
<td width="508" style="padding: 0 0px 0 0;" class="container" colspan="1" valign="top">
<table width="508" class="container" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left" style="font-size: 18px;font-family: 'Roboto Condensed','Helvetica',Arial,sans-serif; font-weight: none; padding:0 0 10px 0; line-height: normal;">
<a href="%%=redirectTo(@mentionTargetURL5)=%%" style="font-size: 18px;color: #000000;text-decoration:none;font-family: 'Roboto Condensed','Helvetica',Arial,sans-serif; font-weight: none; padding:0 0 10px 0; line-height: normal;">%%=v(@mentionPostName5)=%%</a>
</td>
</tr>
%%[if not empty(@mentionPostBody5) then]%%
<tr>
<td align="left" style="font-size: 14px;font-family: 'Roboto Condensed','Helvetica',Arial,sans-serif; font-weight: none; padding:0 0 10px 0; line-height: normal; color: #606060;">
%%=v(@mentionPostBody5)=%% .. <a href="%%=redirectTo(@followedReplyTargetUR5L)=%%" target="_blank" style="font-size: 14px;font-family: 'Proxima Nova','Helvetica',Arial,sans-serif; font-weight: normal; text-decoration: none; color: #007cb0;">read more</a>
</td>
</tr>
%%[endif]%%
<tr>
<td align="left" style="padding: 0px 0 0px 0; font-size: 14px;font-family: 'Proxima Nova','Helvetica',Arial,sans-serif; color: #3a3b3c;">
<a href="%%=redirectTo(@mentionActorAccountUrl5)=%%" target="_blank" style="font-size: 14px;font-family: 'Proxima Nova','Helvetica',Arial,sans-serif; font-weight: normal; text-decoration: none; color: #007cb0;">%%=v(@mentionRecipientName)=%%</a> responded to your post on %%=v(@mentionDate)=%%.
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<!-- End script
%%[
else
endif next @i endif
]%%
-->
<tr>
<td style="padding: 7px 0 0 0;">
<table width="560" cellpadding="0" cellspacing="0" borde="0" class="container">
<tr>
<td align="center" valign="middle" style="padding:2px 2px 3px 1px; box-shadow: 2px 2px 2px 0 rgba(0, 0, 0, 0.09);" bgcolor="#dfdfdf">
<table width="558" class="container" border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff">
<tr>
<td style="padding:20px 20px 20px 20px; font-size: 14px;" align="left">
<table width="508" class="container" border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff">
<tr>
<td width="508" style="padding: 0 0px 0 0;" class="container" colspan="1" valign="top">
<table width="508" class="container" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left" style="font-size: 18px;font-family: 'Roboto Condensed','Helvetica',Arial,sans-serif; font-weight: none; padding:0 0 10px 0; line-height: normal;">
<a href="%%=redirectTo(@mentionTargetURL6)=%%" style="font-size: 18px;color: #000000;text-decoration:none;font-family: 'Roboto Condensed','Helvetica',Arial,sans-serif; font-weight: none; padding:0 0 10px 0; line-height: normal;">%%=v(@mentionPostName6)=%%</a>
</td>
</tr>
%%[if not empty(@mentionPostBody6) then]%%
<tr>
<td align="left" style="font-size: 14px;font-family: 'Roboto Condensed','Helvetica',Arial,sans-serif; font-weight: none; padding:0 0 10px 0; line-height: normal; color: #606060;">
%%=v(@mentionPostBody6)=%% .. <a href="%%=redirectTo(@followedReplyTargetURL6)=%%" target="_blank" style="font-size: 14px;font-family: 'Proxima Nova','Helvetica',Arial,sans-serif; font-weight: normal; text-decoration: none; color: #007cb0;">read more</a>
</td>
</tr>
%%[endif]%%
<tr>
<td align="left" style="padding: 0px 0 0px 0; font-size: 14px;font-family: 'Proxima Nova','Helvetica',Arial,sans-serif; color: #3a3b3c;">
<a href="%%=redirectTo(@mentionActorAccountUrl6)=%%" target="_blank" style="font-size: 14px;font-family: 'Proxima Nova','Helvetica',Arial,sans-serif; font-weight: normal; text-decoration: none; color: #007cb0;">%%=v(@mentionRecipientName)=%%</a> responded to your post on %%=v(@mentionDate)=%%.
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<!-- End script
<!--End Content -->
<tr>
<td align="center" class="mobile-pad-top-20" style="padding: 22px 0 0 0; font-size: 16px;font-family: 'Proxima Nova','Helvetica',Arial,sans-serif; font-weight: none; color: #3a3b3c; line-height: normal;">
<a href="%%=redirectTo(@mentionUserAccountUrl)=%%" target="_blank" style="font-size: 16px;font-family: 'Proxima Nova','Helvetica',Arial,sans-serif; font-weight: normal; text-decoration: none; color: #007cb0;">
See all your posts
</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- -->
<!-- -->
<!--END -->
LookupOrderedRows
is set to return 3 rows and if the result returns 3 successful rows then it will loop through 3 times displaying 3 results. I haven't tested your code but visually, this seems to be the case as to why you may be experiencing duplicate sections.for @i = 1 to @rowCount do IF @i==1 Then ... elseif @i==2 then ... elseif @i==3 then ... else ... endif next @i